JSON的输出方式
JsonMessage msg = new JsonMessage();
msg.setId(5);
msg.setMsg("登录成功!");
msg.setLocation(request.getContextPath() + "/front/customer/index.jsp");
String json = JSONObject.toJSONString(msg);
response.getWriter().println(json);
PrintWriter方式
PrintWriter out =response.getWriter();
out.println("<script>");
out.println("window.alert('请输入正确的验证码');");
out.println("window.location.href='"+request.getContextPath()+"/index.jsp';");
out.println("</script>");
CSS
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/list.css">
JS中:
url:"${pageContext.request.contextPath}/CustomerServlet?customerAction=resetPassword"
<script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
window.location.href="${pageContext.request.contextPath}/PreOrderServlet?preOrderAction=allPreOrderListLike";
action中:
action="${pageContext.request.contextPath}/CustomerServlet"