81,092
社区成员
发帖
与我相关
我的任务
分享
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="LoginAction" method="post">
用户名<input type="text" name="username">
密码<input type="text" name="password">
<input type="submit" value="登录">
</form>
</body>
</html>
<package name="testactionpackage" extends="struts-default" namespace="/">
<action name="LoginAction" class="com.action.LoginSystemAction">
<result name="SUCCESS">/success.jsp</result>
<result name="ERROR">/error.jsp</result>
</action>
</package>
package com.action;
import com.opensymphony.xwork2.ActionSupport;
public class LoginSystemAction extends ActionSupport
{
private String username;
private String password;
@Override
public String execute()throws Exception
{
if("test".equals(username)&&"123456".equals(password))
{
return "SUCCESS";
}else{
System.out.println(username);
System.out.println(password);
return "ERROR";
}
}
public String getusername()
{
return username;
}
public void setusername(String username)
{
this.username=username;
}
public String getpassword()
{
return password;
}
public void setpassword(String password)
{
this.password=password;
}
}