Struts2 configuration package default Action learning notes

Source: Internet
Author: User
Tags i18n

The following small series will share with you an article on the Struts2 configuration package default Action learning notes. If you are interested, please refer


When a front-end request is sent to the struts framework, if the request sent at this time is not configured in strtus. xml, the following error occurs:

HTTP Status 404-There is no Action mapped for namespace/and action name dasddion.


1. For example, our front-end request is:

LoginAction

2. The content of our struts configuration file is as follows:

The Code is as follows: Copy code


<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE struts PUBLIC "-// Apache Software Foundation // DTD Struts Configuration 2.1 // EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<Struts>
<Constant name = "struts. custom. i18n. resource" value = "mess"/>
<Constant name = "struts. i18n. encoding" value = "GBK"/>
<Package name = "default" extends = "struts-default">
<Default-action-ref name = "myAction"/>
<Action name = "myAction" class = "org. Rudiment. action. LoginAction">
<Result name = "input">/login. jsp </result>
<Result name = "error">/error. jsp </result>
<Result name = "success">/welcom. jsp </result>
</Action>
</Package>
</Struts>


3. Description:

Strtus. only one action name = "myAction" is configured in xml. struts finds the default action to process the request because there is no matching action in the current request, as shown in the preceding figure, <default-action-ref name = "myAction"/> the default action is myAction, that is, when the corresponding action cannot be found based on the request under this package, the Action named myAction will be used to process the business requirements, if <default-action-ref name = "myAction"/> is not configured, an error is displayed at the beginning of the document.

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.