直接在三个页面的开头调用此servlet的相关检查方法
解决方案 »
- 大型网站都是用什么语言写的 ?
- 紧急求助!tomcat下java.io.IOException: reading encoded JPEG Stream 问题
- 这是tomcat的问题吗? 数组下标溢出!!
- JSP 通过URL传递汉字,为奇数个,最后一个为乱码?为偶数个,则正常显示?
- 如何让jsp中表格自动伸缩的问题
- 一个奇怪的问题
- 各位救命呀,ORACLE数据库中的CLOB类型字段在保存XML文档的时候,无法正确处理“镕昉”这两个子,其他的中文都正常
- 一个小问题,
- applet里能访问数据库嘛? ????????????????/
- jsp里 Blob 字段存取问题
- springmvc 整合shiro问题 急!!!!
- spring jar包官网地址
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
} /**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String resPath = request.getParameter("resPath");
if("a".equals(resPath)){
request.getRequestDispatcher("/a.jsp").forward(request, response);
}else if("b".equals(resPath)){
request.getRequestDispatcher("/b.jsp").forward(request, response);
}else if("c".equals(resPath)){
request.getRequestDispatcher("/c.jsp").forward(request, response);
}
}
String resPath = request.getParameter("resPath");
这句话是获取表单用的吧,能用来获取请求的地址?
<filter>
<filter-name> servlet</filter-name>
<filter-class>servlet全路径 </filter-class>
</filter>
filter-mapping>
<filter-name>servlet</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
String resPath = request.getParameter("resPath");
这句话是获取表单用的吧,能用来获取请求的地址?
不一定要表单的,直接在URL后面加参数也可以的,像这样:/loginServlet?param=a
这个是在几乎所有框架中通用的做法dispatch servlet
String password = request.getParameter("password");
Map<String, String> messages = new HashMap<String, String>();if (username == null || username.isEmpty()) {
messages.put("username", "Please enter username");
}if (password == null || password.isEmpty()) {
messages.put("password", "Please enter password");
}if (messages.isEmpty()) {
User user = userService.find(username, password); if (user != null) {
request.getSession().setAttribute("user", user);
response.sendRedirect(request.getContextPath() + "/home");
return;
} else {
messages.put("login", "Unknown login, please try again");
}
}request.setAttribute("messages", messages);
request.getRequestDispatcher("/WEB-INF/login.jsp").forward(request, response);
String resPath = request.getParameter("resPath");
这句话是获取表单用的吧,能用来获取请求的地址?如果你是通过URL的方式,自然可以啊, action="*.do?resPath=a"