Eclipse、Tomcat安装配置及部署教程 先看这个https://blog.csdn.net/zeroheitao/article/details/108970713
tomcat安装 看这个 https://blog.csdn.net/qq_51452157/article/details/122459707
eclipse没有sever选项 看这个 https://blog.csdn.net/boringboo/article/details/124980241
eclipse新建项目没有Dynamic Web Project 看这个https://blog.csdn.net/qq_29774003/article/details/108023831
解决tomcat项目标红https://blog.csdn.net/yjh_dream/article/details/79726467
项目没有pom.xml选项看这个 https://blog.csdn.net/Roger_CoderLife/article/details/90601845
java对象转JSON https://zhuanlan.zhihu.com/p/39870112
c:forEach无法使用解决方案:https://blog.csdn.net/winter2121/article/details/84978273
https://blog.csdn.net/admin_web/article/details/121733872
跳转jsp
String user = "我是一些中间处理的数据";
// 放入Request中:
req.setAttribute("user", user);
// 转给home.jsp:
req.getRequestDispatcher("/WEB-INF/home.jsp").forward(req, resp);
定义接口
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Base64; //引用工具类
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(urlPatterns = "/getUser")
public class getUser extends HttpServlet {
private static final long serialVersionUID = 1L;
String[] ss = new String[10];
String name ="xcy";
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("application/json;charset=utf-8");
resp.setStatus(200);
//response.sendError(500);
JSONObject jObject=new JSONObject();
jObject.put("username", "xiejava");
jObject.put("sex", "man");
jObject.put("age", 38);
jObject.put("email", "xiejava@ishareread.com");
String json2=jObject.toJSONString();
//获取输出流
PrintWriter out = resp.getWriter();
out.println(json2);
}
}