日期:2014-05-20 浏览次数:20867 次
<servlet> <servlet-name>jspDefault</servlet-name> <servlet-class>com.xxx.JspDefault</servlet-class> </servlet> <servlet-mapping> <servlet-name>jspDefault</servlet-name> <url-pattern>/jsp</url-pattern> </servlet-mapping> --------------------- public class JspDefault extends HttpServlet{ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException , IOException { String toUrl = request.getContextPath()+"/jsp/myIndex.jsp"; response.sendRedirect(toUrl); } }
------解决方案--------------------
整上一个过滤器
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse)response;
HttpServletRequest req = (HttpServletRequest)request;
//判断一下 请求字符串 为http://localhost:8080/Item/jsp
//req.getRequestDispatcher("/login.do?method=loginIn").forward(req, res);
//跳到你指定的页面上 上面可以参考
chain.doFilter(request, response);
}
------解决方案--------------------
req.getRequestDispatcher("/login.do?method=loginIn").forward(req, res);
chain.doFilter(request, response);