我使用春天 在我的JSP项目:
我对所有 HTML 请求进行映射 :
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
和
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
所以每个请求都交给调度员
我有一个 JSP 页面, 它有 session.getAttritte ()
, 将会话变量返回到该页面 。
如果某些用户直接访问该页面,则会话变量返回为空。
为避免这种情况,我试图在联合战略规划网页中增加以下一行:
<%@page errorPage="error.jsp"%>
JSP 文件位于该页面所在的同一目录中, 但没有运气 。 我得到了以下例外 : -- & gt; 404
我还尝试了一个组合,所以错误页面会指出如下:
然后,我在主计长中增加了一个条目如下:
@RequestMapping("/xyz/result/error")
public ModelAndView showErrorPageEng() {
return new ModelAndView("errorpage", "comm和", null);
}
问题的最新部分:
我有以下错误页的牌项:
<definition name="errorpage" extends="basic"
template="/error/error_layout.jsp">
<put-attribute name="error" value="/error/error.jsp"/>
</definition>
并修改JSP的代码如下:
<%@page errorPage="error.html"%>
上述路径/xyz/结果/错误如下:
ROOT/xyz/result/error
我可以访问文件mydomain/xyz/result/error.html
,但是没有发生同样的情况,但以下例外:
<强 > 启动为 强>
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
at org.apache.jsp.error_jsp._jspService(error_jsp.java:63)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)
**和 ends as**
at org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:220)
at org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:103)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:659)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:678)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:633)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:322)
at org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549
)