[Struct2] modifying the. Action Suffix of struts2

Source: Internet
Author: User

Dizzy, the whole night, is unable to access, originally because of the use of the suffix ". Do. Change the suffix of ". Action" to access the service. And it can only be in the form of "XXX. Action". Otherwise, it cannot be accessed.

It seems that the filter mechanism of struts2 is not very clear.

However, I cannot set web. XML as follows:

<Filter-mapping>
<Filter-Name> struts2 </filter-Name>
<URL-pattern> *. DO </url-pattern>
</Filter-mapping>

I think this is not very good. We should be able to customize URL matching.

Why do I have to change it to the "struts. properties" file.

Since "structs. properties" is not modified, you can use the <constant> element in "struts. xml.

The method is as follows:

Add the red part in struts. xml:

<Struts>

......

<Constant name = "struts. Action. Extension" value = "do, Action"/>

......

</Struts>

The value attribute can be set to the desired suffix, value = "do, action", indicating that. Action and. Do can all be accessed.

You can also modify the structs. properties file to set:

You only need to modifyStruts. Action. ExtensionCan be separated by commas (,). For example, "struts. Action. Extension = Do, Action"

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.