First, preface
When Web application development, the address bar input ip+port+appname, usually can jump to the login page. Here are the three ways I know and verify the jump.
Ii. preparatory work
The processing required to use two URLs is as follows:
@At ("/index") @Ok ("Redirect:/tologin") @Filters// indicates that the URL is not filtered (using an empty filter) public void init () { } @At ("/tologin") @Ok ("") // Configure the address path of the login page here @Filters publicvoid Tologin () { }
Three or three ways to jump to the login page
1. Configuration <welcome-file-list> index.jsp page path for presence
<welcome-file-list> is configured as follows:
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list >
Here index.jsp in the WebContent directory. and add the following code to the index.jsp:
<% request.sendredirect ("/index")%>
2, configuration <welcome-file-list> for a URL. As shown below:
<welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list >
Here: index.html is a URL path. At this point, you need to add an empty index.html file under the WebContent directory. This way, when you enter Ip+port+appname, the/index.html path is accessed by default. This allows you to jump to the login page.
Note : If you use struts2, the ur name may be index.action. In this case, you need to add: index.action empty file in the WebContent directory. The file name is consistent with the configured URL.
3, the use of uriwriter implementation does not configure <welcome-file-list> and do not add files such as index.jsp or index.html, jump to the login page function. "It's not recommended because it complicates simple problems." 】
Step 1: Introduce the Urlwriter jar package
Step 2: Add the following configuration in Web. xml:
<filter> <filter-name>UrlRewriteFilter</filter-name> <filter-class> org.tuckey.web.filters.urlrewrite.urlrewritefilter</filter-class> </filter> < filter-mapping> <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/* </url-pattern> </filter-mapping>
Step 3: Add a file named: Urlrewrite.xml under Web-inf (Note: The filename can only be urlrewrite.xml), the contents are as follows:
<?xml version= "1.0" encoding= "Utf-8"? ><! DOCTYPE urlrewrite Public "-//tuckey.org//dtd urlrewrite 3.2//en" "Http://tuckey.org/res/dtds/urlrewrite3.2.dtd "><urlrewrite> <rule> <from>^/$</from> <to>/index</to> </rule> </urlrewrite>
That is, when the path is "/", it will be converted to execute "/index" by default in the form of forward. In order to achieve the/index access to the login page to achieve the jump.
Iv. References:
1. Through configuration <welcome-file-list> Implementation home page jump: http://blog.csdn.net/zzq900503/article/details/44460963
2, Urlwriter use: http://blog.csdn.net/lgg201/article/details/5329364
Http://www.osblog.net/blog/507.html
==================================================================================================
Above only for my personal beginner Nutz a little bit of experience, if there is not correct and inappropriate place, please point out a lot, common progress!
If reproduced, please specify the source. Thank you!
How the home page jumps to the login page in the Nutz_web app