我用的是Resin2.1.6, 配404错误时转到指定页面,有两个问题一直解决不了
  1.配的时候写location="\error.html"这个没有问题。但是我想写一个绝对路径,比如写D:/error.html.这样就不行,或者我写http://localhost/error.html也不行。不知道什么原因。
  2。我的error.html的页面里有引用一张图片。和error.html是放在同一个目录的。所以我路径就直接写src="errorImg.jpg".但是我输入http://localhost/fdas(fdsa是乱写的),就会跳到error.html页面并且会显示图片,但是我打入http://localhost/fdsa/fdsa,会跳到error.html.但是不会显示图片。我猜是启动Resin的时候就把error.html页面找到并且载入进容器了。等出现404的时候就直接显示出来。所以我输入http://localhost/fdas时好像会转到http://localhost/error.html.但我输入http://localhost/fdsa/fdsa时会转到http://localhost/fdsa/error.html.所以图片就找不到。不知道是不是这样.哪位大侠帮忙解答一下,谢谢~~~

解决方案 »

  1.   

    错误页面是类似于当前错误地置页面include过来,当作报错信息处理,所以你的错误页面中的代码,应该使用类似绝对路径或者
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    用base指向路径,想想inlude的方式,相对路径都回不能正常显示的