struts2实现注册及登录

zhuce.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>




Insert title here


新用户注册
用户名:
密码:
width="120ppx" />

 

denglu.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>




Insert title here


用户登录
用户名:
width="120ppx" />

 

UserAction.java

package com.amos.web.action;

import com.opensymphony.xwork2.ActionSupport;

/**
* @ClassName: UserAction
* @Description: 用户管理,将相关的action封装到一个类中
* @author: amosli
* @email:[email protected]
* @date Jan 8, 2014 1:06:00 AM
*/
public class UserAction extends ActionSupport {
private static final long serialVersionUID = -6275534406709255984L;
private String username;
private String password;

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;
}

// 用户注册
public String register() throws Exception {

return "toRegisterJsp";
}

// 用户登录
public String login() throws Exception {
return "toLoginJsp";
}

}

 

user_struts.xml

 1 
 2 DOCTYPE struts PUBLIC
 3     "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
 4     "http://struts.apache.org/dtds/struts-2.3.dtd">
 5 
 6 
 7     <package name="user" namespace="/" extends="struts-default">
 8         class="com.amos.web.action.UserAction"
 9             method="register">
10             
11             /register_success.jsp
12             
13         
14         class="com.amos.web.action.UserAction"
15             method="login">
16             
17             /login_success.jsp            
18             
19         
20     package>
21 

Login_success.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>




Insert title here


登录成功!

用户名:

register_success.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"  %>
    




Insert title here


注册成功

用户名: 密码:

 

转载于:https://www.cnblogs.com/yeyujun/p/11140570.html

你可能感兴趣的:(struts2实现注册及登录)