在我的项目中在客户端工作的团队要求我编写一个示例测试页面,并为他们提供一个可以点击并返回200的工作URL.他们要求我也提供样本请求正文.这是我要给他们的请求主体.
{ "MyApp": { "mAppHeader": { "appId": "", "personId": "", "serviceName": "", "clientIP": "", "requestTimeStamp": "", "encoding": "", "inputDataFormat": "", "outputDataFormat": "", "environment": "" }, "requestPayload": { "header": { "element": "" }, "body": { "request": { "MyTestApp": { "data": { "AuthenticationRequestData": { "appId": "", "appPwd": "" } } } } } } } }
要开发示例页面,我不知道从哪里开始.请放弃你的downvotes(如果问题似乎无关紧要),因为我没有使用JSP Servlets的经验.
这就是我现在所拥有的.它是一个简单的登录页面 -
<%@ page language="java" contentType="text/html; charset=windows-1256" pageEncoding="windows-1256" %>Login Page
这是我的servlet类 -
package com.test; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class TestClient extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public TestClient() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/json"); App app = new App(); app.setAppID(request.getParameter("appID")); app.setAppPassword(request.getParameter("appPwd")); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } }
我的应用程序是一个简单的Java类,它有appID,appPassword有getter和setter,所以我不打算在这里发布.
我的问题是 - 我这样做是对还是100%错了?请给我你的建议.