0
dynamiclly更改web.xml中的歡迎文件我想2例,以顯示不同的指數的HTML:如何根據傳入的ROOT要求
承認,如果該請求來自移動設備,以便重定向歡迎-file到mobile.html,
如果來自網頁的請求重定向到第二受歡迎的文件web_index.html
我怎麼可以做一個邏輯,歡迎文件選擇?
<welcome-file-list> <welcome-file>mobile.html</welcome-file> <welcome-file>web_index.html</welcome-file>
P.S我用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>
謝謝,我會檢查它,怎麼樣web.xml中,我又該如何配置它呢?以及如何設置歡迎文件? – VitalyT
在web.xml的 index.html welcome-file>的welcome-file-list中設置一個歡迎文件'通常的名字是'index.html',但是你可以使用你想要的名字 –
pedrofb