上下文路径跳转方式的写法说明

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"
发布了143 篇原创文章 · 获赞 92 · 访问量 8883

猜你喜欢

转载自blog.csdn.net/weixin_42995083/article/details/105053614
今日推荐