如何在GlassFish 3.0.1 Community Edition中更改默认错误页面(状态404 - 未找到)?

gen*_*nad 5 glassfish glassfish-3

如何在GlassFish 3.0.1 Community Edition中更改默认错误页面(状态404 - 未找到)?

ahm*_*met 9

创建一个页面404.htm

例如:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>404 - Page not found.</title>
    <style type="text/css">
        body{
            font-family:tahoma;
        }
    </style>
</head>
<body>
    <div class="firstWarning">Page not found.</div>
    <img src="css/images/404.jpg" class="imgWarning" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

并将其保存为404.htm并将其保存到您的

${com.sun.aas.instanceRoot}/docroot/
Run Code Online (Sandbox Code Playgroud)

例如:

/usr/share/glassfish3/glassfish/domains/domain1/docroot/
Run Code Online (Sandbox Code Playgroud)

输入:

https://ip_address:4848/web/configuration/virtualServerEdit.jsf?name=server&configName=server-config
Run Code Online (Sandbox Code Playgroud)

将新属性添加到服务器

Name:send-error_1
Value:code=404 path=${com.sun.aas.instanceRoot}/docroot/404.htm reason=Resource_not_found
Description: 404 Error Page
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述 在此输入图像描述 在此输入图像描述


jav*_*ude 6

我建议使用glassfish控制台并在此处添加属性:

配置|虚拟服务器|服务器

name:send-error_1

value:code = 404 path =/tmp/404.html reason = Resource_not_found

增加几个错误的数量,例如.send_error_2,3,4 ...

路径是您的域文件夹的绝对路径或相对路径.

看看http://javadude.wordpress.com/2010/12/07/customized-error-pages-for-glassfish-v3/