Have seen some struts2 videos before.
Now review the next struts2. Found this problem
Most of the solutions on the web don't mention this, and 1% of the articles mention the new version of the method in struts.
There is no Action mapped for Namespace/and action name XXX
Http://localhost:8080/Struts2Learn/loginAction_login.action
The reason is unknown.
Workaround:
The use of the wildcard * method.
The method attribute is not required in the configuration of action in Struts.xml under the struts-2.5.10.1 version
Struts.xml
1<?xml version= "1.0" encoding= "UTF-8"?>2 3<!DOCTYPE Struts4Public "-//apache software foundation//dtd Struts Configuration 2.5//en"5"Http://struts.apache.org/dtds/struts-2.5.dtd" >6<struts>7< PackageName= "User" namespace= "/"extends= "Struts-default" >8<action name= "Loginaction_*"class= "Com.learn.LoginAction"Method={1}><!--do not need method={1}-->9<result name= "Success" >/loginSuccess.jsp</result>Ten<result name= "fail" >/loginFail.jsp</result> One</action> A</ Package> -</struts>
Com.learn.LoginAction
1 PackageCom.learn;2 3 ImportCom.opensymphony.xwork2.ActionSupport;4 5 Public classLoginactionextendsActionsupport {6 7 Private Static Final LongSerialversionuid = 1L;8 PrivateString username;9 PrivateString password;Ten One PublicString GetUserName () { A returnusername; - } - the Public voidSetusername (String username) { - This. Username =username; - } - + PublicString GetPassword () { - returnpassword; + } A at Public voidSetPassword (String password) { - This. Password =password; - } - PublicString Loginn ()throwsException { -SYSTEM.OUT.PRINTLN ("Login ()"); - return"Success"; in - } to +}
Access connection
Http://localhost:8080/Struts2Learn/loginAction_loginn.action
There is no action mapped for Namespace/and action name wildcard problem