Struts2 exception: HTTP Status 404-there is no action mapped for action name Addbook.

Source: Internet
Author: User

HTTP Status 404-there is no action mapped for action name Addbook.

  

This error message occurs when the address bar is accessed, and there are three reasons why this exception can occur:

1. The name or location of the Struts.xml file may be incorrectly written.

2. The contents of the Struts.xml file may be incorrect.

3. It is possible that the Struts.xml file was edited in a sub-module mode without introducing the XML file under the module into the core profile struts.xml of struts (my exception for this reason)

    

The correct struts.xml template:

1. Sub-modules Struts.xml and Book.xml (struts.xml core profile, book.xml module configuration file. Only need to introduce book.xml to Struts.xml)

Book.xml:
1 <?XML version= "1.0" encoding= "UTF-8"?>2 <!DOCTYPE Struts public3 "-//apache software foundation//dtd Struts Configuration 2.3//en"4 "Http://struts.apache.org/dtds/struts-2.3.dtd">5 <Struts>6     < Packagename= "Bookaction"extends= "Struts-default"namespace= "/book">7         <Actionname= "Addbook"class= "Cn.geore.bookaction.BookAction"Method= "Addbook">8             <resultname= "Success">/jsps/one/addbook.jsp</result>9         </Action>Ten          One         <Actionname= "Updatebook"class= "Cn.geore.bookaction.BookAction"Method= "Updatebook"> A             <resultname= "Success">/jsps/one/updatebook.jsp</result> -         </Action> -     </ Package> the </Struts>
Struts.xml:
1 <?XML version= "1.0" encoding= "UTF-8"?>2 <!DOCTYPE Struts public3 "-//apache software foundation//dtd Struts Configuration 2.3//en"4 "Http://struts.apache.org/dtds/struts-2.3.dtd">5 <Struts>6     <constantname= "Struts.i18n.encoding"value= "UTF-8"></constant>7     <!--introduction of configuration files for external struts modules -8     <!--<include file= "Cn/geore/action/one.xml" ></include> -9     <includefile= "Cn/geore/bookaction/book.xml"></include>Ten </Struts>

2. Struts.xml of modules

1 <?XML version= "1.0" encoding= "UTF-8"?>2 <!DOCTYPE Struts public3 "-//apache software foundation//dtd Struts Configuration 2.3//en"4 "Http://struts.apache.org/dtds/struts-2.3.dtd">5 <Struts>6     < Packagename= "Bookaction"extends= "Struts-default"namespace= "/book">7         <Actionname= "Addbook"class= "Cn.geore.bookaction.BookAction"Method= "Addbook">8             <resultname= "Success">/jsps/one/addbook.jsp</result>9         </Action>Ten          One         <Actionname= "Updatebook"class= "Cn.geore.bookaction.BookAction"Method= "Updatebook"> A             <resultname= "Success">/jsps/one/updatebook.jsp</result> -         </Action> -     </ Package> the </Struts>

Struts2 exception: HTTP Status 404-there is no action mapped for action name Addbook.

Related Article

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.