struts2 初学求解问题
问题:
HTTP Status 404 - There is no Action mapped for action name loginuser.
--------------------------------------------
type Status report
message There is no Action mapped for action name loginuser.
description The requested resource (There is no Action mapped for action name loginuser.) is not available.
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<include file="trylogin.xml"/>
</struts>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="login" namespace="/jsp" extends="default">
<action name="loginuser" class="loginaction.loginaction" method="judge">
<result name="success">/jsp/success.jsp</result>
<result name="fail">/jsp/fail.jsp</result>
</action>
</package>
</struts>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>
login.jsp
</title>
</head>
<body>
<s:form action="loginuser.action">
<s:textfield key="username"/>
<s:password key="password"/>
<s:submit/>
</s:form>
</body>
</html>
package loginaction;
public class loginaction
{
private String username;
private String password;
public void setUsername(String username)
{
this.username=username;
}
public String getUsername()
{
return username;
}
public void setPassword(String password)
{
this.password=password;
}
public String getPassword()
{
return password;
}
public String judge()
{
if(username.equals("luozixuan")&&password.equals("123456"))
{
return "success";
}
else
{
return "fail";
}
}
}