81,092
社区成员
发帖
与我相关
我的任务
分享
<%@ page contentType="text/html;charset=gbk"%>
<html>
<body>
<form action="login.action">
<input type="text" name="username"/>
<br/>
<input type="password" name="password"/>
<br/>
<input type="submit" value="登陆"/>
</form>
</body>
</html>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">
<filter>
<filter-name>s2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>s2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</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>
<package name="default" extends="struts-default" namespace="/">
<action name="login" class="abc.LoginAction">
<result>/success.jsp</result>
</action>
</package>
</struts>
package abc;
public class LoginAction
{
String username;
String password;
public LoginAction()
{}
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 execute()
{
if(username.equals("") || username == null)
{
return "error";
}
else
{
return "success";
}
}
}