The way to jump to the logon page on the home page of the nutz_web application.

Source: Internet
Author: User

The way to jump to the logon page on the home page of the nutz_web application.

I. Preface

When developing a web application, you can enter ip + port + appName in the address bar to jump to the logon page. The following describes three redirect methods that I know and have verified.

2. Preparations

The two URLs must be processed 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 logon page here @ Filters public void toLogin (){}

 

3. Three login page Jump Methods

1. Configure <welcome-file-list> as the path of the existing index. jsp page.

<Welcome-file-list> the configuration is as follows:

    <welcome-file-list>       <welcome-file>index.jsp</welcome-file>    </welcome-file-list>

Here, index. jsp is in the WebContent directory. Add the following code to index. jsp:

<%    request.sendRedirect("/index")%>

2. Configure <welcome-file-list> As a url. As follows:

    <welcome-file-list>       <welcome-file>index.html</welcome-file>    </welcome-file-list>

Here: index.html is a url path. Upload an empty index.html file in the webcontentdirectory. In this case, when you enter ip + port + appName, the path/index.html will be accessed by default. This allows you to jump to the logon page.

NOTE: If struts2 is used, ur name may be index. action. Add the index. action empty file in the WebContent directory. The file name is consistent with the configured url.

3. Use UriWriter to jump to the logon page without configuring <welcome-file-list> to add files such as index.jspor index.html. [This is not recommended because it will complicate the simple problem .]

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 the WEB-INF (Note: The file name can only be urlrewrite. xml) with the following content:

<?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 is converted into execution "/index" in the form of forward by default ". In this way, access to/index is realized, and the logon page is redirected.

Iv. References:

1. Achieve home page Jump by configuring <welcome-file-list>: 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

 

========================================================== ========================================================== ============================

The above is just a little bit of experience I have learned from my personal experience in using nutz. If there are any errors or inconveniences, please point out more and make progress together!

If any reprint is found, specify the source. Thank you!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.