When Struts2 is configured in Eclipse, There is no Action mapped for action name loginAction.

Source: Internet
Author: User

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;

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.