【发布时间】:2016-12-29 09:56:25
【问题描述】:
我想在两种情况下显示不同的索引html:
识别请求是否来自移动设备,因此将欢迎文件重定向到 mobile.html,
-
如果请求来自网页重定向到第二个欢迎文件 web_index.html
我该如何做一个逻辑,选择哪个欢迎文件??
<welcome-file-list> <welcome-file>mobile.html</welcome-file> <welcome-file>web_index.html</welcome-file>
PS 我正在使用 java ejb - Tomcat
我的 WEB.XML 如下:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<security-constraint>
<display-name>Entire Application</display-name>
<web-resource-collection>
<web-resource-name>Secured area</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>superuser</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<display-name>administration</display-name>
<web-resource-collection>
<web-resource-name>administration area</web-resource-name>
<url-pattern>/admin.html</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>superuser</role-name>
<role-name>admin</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-role>
<role-name>superuser</role-name>
</security-role>
<session-config>
<session-timeout>60</session-timeout>
<cookie-config>
<http-only>true</http-only>
<path>/</path>
</cookie-config>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
<security-constraint>
<display-name>Unsecured</display-name>
<web-resource-collection>
<web-resource-name>Unsecured area</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<filter>
<filter-name>LogoutFilter</filter-name>
<filter-class>com.ngsoft.tt.ROOT.filters.LogoutFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LogoutFilter</filter-name>
<url-pattern>/logout</url-pattern>
</filter-mapping>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>TitanLogin</realm-name>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/error.html</form-error-page>
</form-login-config>
</login-config>
<welcome-file-list>
<welcome-file>welcome.html</welcome-file>
</welcome-file-list>
</web-app>
【问题讨论】:
标签: java web-services tomcat servlets web.xml