In struts2, <welcome-File> index. Action </welcome-File> directly sets action, 404 Solution

Source: Internet
Author: User

In the past few days, the access to the project page is changed to. Action access, and a problem occurs when you modify the home page. Modify <welcome-File> index. Action </welcome-File> in the web. xml file to this way. When you access the home page, the system reports a 404 error, which means the file cannot be found. There are two solutions for online query.
Method 1: Create an empty index. Action file under webroot. This method is simple and practical and is strongly recommended.
Method 2: Because the welcome-file must be an existing file, not an action or Servlet Path, you can set a goindex such as <welcome-File>. JSP </welcome-File>, and then goindex. JSP write <JSP: Forward page = "index. action "/>. This means that a JSP page is used to forward requests to the action.

Method 3: Use meta redirection in index.html.

Actions: <meta HTTP-EQUIV = "refresh" content = "0; url = max/helloworld. Action">

Where,

Content = "1 is the time control, indicating that the page to jump is automatically redirected in 1 second.
Content = "0" indicates that the page will jump to the page you want to jump to immediately.
URL is the path to jump

----------------------------------------------

In struts2, it is also very special:

Cause:

Struts2 uses a filter to process requests. By default, it monitors URL address changes.

The following operations are required:

Step 1:
Modify in Web. xml
<Filter-mapping>
<Filter-Name> struts2 </filter-Name>
<URL-pattern>/* </url-pattern>
<Dispatcher> request </dispatcher>
<Dispatcher> forward </dispatcher>
</Filter-mapping>
Step 2:
Add in Web. xml
<Welcome-file-List>
<Welcome-File> index. jsp </welcome-File>
</Welcome-file-List>
Step 3:
Homepage jump statement
The content of index. jsp is as follows:
<JSP: Forward page = "helloworld. Action"> </jsp: Forward>

Or use method 3 !!!

From: http://blog.sina.com.cn/s/blog_4b5bc0110100yrn2.html

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.