When struts2 is configured in eclipse, the following error occurs: There is no Action mapped for action name loginAction when Struts2 is configured in Eclipse. -The [unknown location] error is checked as follows: 1. Ensure struts. the xml file name is case-insensitive: struts. xml (all in lower case, I got an error here) 2. Make sure struts. the xml file is in the src directory (very important! I will focus on this later) Appendix: web. xml
1 <? xml version= "1.0" encoding= "UTF-8" ?>
2 Struts struts2 org.apache.struts2.dispatcher.FilterDispatcher struts2 /* login.jsp
Struts. xml
<? Xml version = "1.0" encoding = "UTF-8"?> <! "-// Apache Software Foundation // DTD Struts Configuration 2.3 // EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <name = "default" = "struts-default"> <action = "com. lizanhong. action. loginAction "> <! -- Define the ing between the logical view and physical resources --> <result name = "error"> index. jsp </result> <result>/WEB-INF/main. jsp </result> </action> </struts>
Index. jsp
<% @ Page language = "java" contentType = "text/html; charset = GB18030 "pageEncoding =" GB18030 "%> <% @ taglib prefix =" s "uri ="/struts-tags "%> <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
Error summary:
1. The <action> tag name = "LoginAction" in struts. xml must be consistent with the <form> tag action = "LoginAction" in index. jsp;
2. The <package> label namespace = "/" in struts. xml must be consistent with the <form> label namespace = "/" in index. jsp;
3. After configuration, restart the server if any modification is made;