如何配置web.xml文件,修改400web.xml 错误页面面

本帖子已过去太久远了,不再提供回复功能。> web.xml配置详解之欢迎页面和异常页面
web.xml配置详解之欢迎页面和异常页面
winson & &
发布时间: & &
浏览:20 & &
回复:0 & &
悬赏:0.0希赛币
web.xml配置详解之欢迎页面和错误页面
  &!-- 应用的欢迎页面
采用list的方式罗列欢迎页面,
  系统会从第一个找到最后一个,找到了文件就不继续往下找了。优先显示前边的。
  &welcome-file-list&
  &welcome-file&index.jsp&/welcome-file&
  &welcome-file&login.jsp&/welcome-file&
  &welcome-file&index.html&/welcome-file&
  &welcome-file&index.htm&/welcome-file&
  &welcome-file&default.html&/welcome-file&
  &welcome-file&default.htm&/welcome-file&
  &welcome-file&default.jsp&/welcome-file&
  &/welcome-file-list&
  &!-- 通过上边welcome-file-lis的配置:我们的应用的欢迎界面或者叫默认界面就是index.jsp,如果index.jsp没找到的话
  就接着往下找:login.jsp,index.html.... --&
  &!-- 配置错误页面
  error-page标签用来配置档应用出现指定错误码的错误时候,有哪个页面来处理这个错误,而不是给用户
  显示系统的错误信息。子标签:
  error-code:系统错误码
  location:应用系统中的处理错误页面。
  &error-page&
  &error-code&404&/error-code&
  &location&/common/404.html&/location&
  &!-- 表示当系统发生404就是不存在请求地址的错误的时候,页面跳转到404.html页面。 --&
  &/error-page&
  &error-page&
  &error-code&500&/error-code&
  &location&/common/error.jsp&/location&
  &!-- 表示当系统发生500也就是操作异常错误的时候,页面跳转到error.jsp页面。 --&
  &/error-page&
  &error-page&
  &exception-type&java.lang.NullPointerException&/exception-type&
  &location&/common/error.jsp&/location&
  &!-- 表示当系统发生空指针异常错误的时候,页面跳转到error.html页面。 --&
  &/error-page&
  &!-- 通过上边对error-apge的配置:当我们系统的系统发生404错误的时候,页面调准到404.html,
  当页面发生服务器错我或者空指针错误的时候,页面跳转到error.html --&
  &/web-app&
本问题标题:
本问题地址:
温馨提示:本问题已经关闭,不能解答。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&web.xml里面配置404问题
你好,想跟你请教个问题:我在web.xml里面设置的404页面只能是静态页面吗?
1.我是用的freemarker,如果设置的页面是静态页面则没问题,如果是jsp页面就会出现解析错误
2.我已经在JfinalConfig里面设置了404错误页面,但是有的404错误是web应用报出的,只能依靠web.xml里面来配置
所以想请教下,404页面在web.xml里面如何设置成动态页面呢?
谢谢了先~~
可以配置jsp页面啊!我这边都没什么问题。
--- 共有 3 条评论 ---
: 嗯,我也是web开发的,不过用的是Jfinal集成freemarker的模式,头疼
不是,我是web开发
我用的Jfinal的freemarker,你的也是吗?
自己解决了,在web.xml里面添加一个freemarker的servlet过滤器放在jfinal过滤器下面,过滤类型设置成.jsp就可以正常解析了,配置代码如下,运行正常,不晓得有没有啥影响啊:
& &&servlet& & & & & &servlet-name&freemarker&/servlet-name& & & & & &servlet-class&freemarker.ext.servlet.FreemarkerServlet&/servlet-class& & & & & & &!-- FreemarkerServlet settings: --& & & & & &init-param& & & & & & & &param-name&TemplatePath&/param-name& & & & & & & &param-value&/&/param-value& & & & & &/init-param& & & & & &init-param& & & & & & & &param-name&NoCache&/param-name& & & & & & & &param-value&true&/param-value& & & & & &/init-param& & & & & &load-on-startup&1&/load-on-startup& & & &/servlet& & & & &servlet-mapping& & & & & &servlet-name&freemarker&/servlet-name& & & & & &url-pattern&*.jsp&/url-pattern& & & &/servlet-mapping&
& & &web.xml 中配置的 404页面并没有走 jfinal 这条通道,所以 jfinal 是无法控制的,jfinal 只能控制经过 JFinalFilter 后出现的 404错误。
& & 所以在 web.xml 中配置的404 按非 jfinal 的 java web项目处理即可
--- 共有 1 条评论 ---
的确,如果是普通的404的话只能自己再配置个解析器来解析,受教了~
求大神解答下~~实在搞不定的话我就只有弄俩静态页面了,也就多点点html代码而已
--- 共有 1 条评论 ---
只能解析一种模板,默认是freemarker,可以设置为jsp
刚试了下,可以设置成jsp,不过里面的freemarker标签没有被解析,啥情况呐~~
@南湖船老大&}

我要回帖

更多关于 web.xml配置404页面 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信