404处理-提高用户体验

      原来开发的时候经常遇到404错误,却从未在意过,但看到一篇博文之后,才忽然发现404错误界面是很难看的,从提高用户体验的角度讲,非常有必要美化一下404错误,或者就是用一个新的页面替换掉原来浏览器默认的404错误。
在使用struts2框架的项目下进行配置,步骤如下:     
1.首先在web.xml中加入一下配置:
class Demo{
    public static void main(String[] args){
        System.out.println("welcome to CSDN!");
    }
}
2. 以上错误帮我们处理了大部分的资源访问错误,但在访问action的时候,仍然 会出现 Could not find action or result 的错误。因为struts2没有相应的actio n来配置相 应错误,所以我们可以在struts.xml中加入一下配置:
<div>
class Demo{
    public static void main(String[] args){
        System.out.println("welcome to CSDN!");
    }
}
</div>
<img src="https://img-blog.csdn.net/20150730204754232?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
</pre></div><pre name="code" class="html">


猜你喜欢

转载自blog.csdn.net/tyzzls/article/details/47156035