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.