本文将阐述springmvc中静态页面的处理、视图解析器以及转发和重定向。
<mvc:resources mapping="/css/*" location="/WEB-INF/css/"></mvc:resources>
<mvc:resources mapping="/js/*" location="/WEB-INF/js/"></mvc:resources>
<mvc:resources mapping="/page/*" location="/WEB-INF/page/"></mvc:resources>
<mvc:resources mapping="/*" location="/"></mvc:resources>
<mvc:default-servlet-handler></mvc:default-servlet-handler>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/page/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
//服务器端跳转
request.getRequestDispatcher("success.jsp").forward(request,response)
return "forward:success.jsp";
//客户端跳转
response.sendRedirect("success.jsp");
return "redirect:success.jsp";
以上就是静态页面的处理、转发和重定向。
原文:https://www.cnblogs.com/alichengxuyuan/p/12554603.html