-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhibin.shao
committed
Dec 5, 2017
1 parent
be7fda6
commit c0e9ab7
Showing
10 changed files
with
406 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<package name="user" extends="struts-default"> | ||
<action name="userAction_*" class="cn.shao.infopublish.struts2.action.UserAction" method="{1}"> | ||
<result name="success">/desktop.jsp</result> | ||
<result name="user_mgr">/usermgr.jsp</result> | ||
<result name="refresh" type="redirectAction">userAction_getAllUser.action</result> | ||
<result name="error">/error.jsp</result> | ||
<result name="failed">/failed.jsp</result> | ||
</action> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cn.shao.infopublish.service.impl; | ||
|
||
import cn.shao.infopublish.bean.User; | ||
import cn.shao.infopublish.dao.UserDao; | ||
import cn.shao.infopublish.service.UserService; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by zhibin.shao on 2017/12/5. | ||
*/ | ||
public class UserServiceImpl implements UserService{ | ||
private UserDao userDao; | ||
|
||
public void setUserDao(UserDao userDao) { | ||
this.userDao = userDao; | ||
} | ||
|
||
public UserDao getUserDao() { | ||
return userDao; | ||
} | ||
|
||
|
||
public void addUser(User user) { | ||
this.userDao.addUser(user); | ||
|
||
} | ||
|
||
|
||
public void deleteUserById(User user) { | ||
this.userDao.deleteUserById(user); | ||
} | ||
|
||
|
||
public User getUserByUsername(String username) { | ||
return this.userDao.getUserByUsername(username); | ||
} | ||
|
||
|
||
public User getUserById(String id) { | ||
return this.userDao.getUserById(id); | ||
} | ||
|
||
|
||
public List getAllUser() { | ||
return this.userDao.getAllUser(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package cn.shao.infopublish.struts2.action; | ||
|
||
import cn.shao.infopublish.bean.User; | ||
import cn.shao.infopublish.service.UserService; | ||
import com.opensymphony.xwork2.ActionContext; | ||
import com.opensymphony.xwork2.ActionSupport; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by zhibin.shao on 2017/12/5. | ||
*/ | ||
public class UserAction extends ActionSupport { | ||
private User user; | ||
|
||
public UserService getUserService() { | ||
return userService; | ||
} | ||
|
||
public void setUserService(UserService userService) { | ||
this.userService = userService; | ||
} | ||
|
||
public List getUserlist() { | ||
return userlist; | ||
} | ||
|
||
public void setUserlist(List userlist) { | ||
this.userlist = userlist; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public User getUser() { | ||
return user; | ||
} | ||
|
||
public void setUser(User user) { | ||
this.user = user; | ||
} | ||
|
||
private String id; | ||
private List userlist; | ||
private UserService userService; | ||
|
||
public String addUser() { | ||
this.userService.addUser(user); | ||
return "refresh"; | ||
} | ||
|
||
public String removeUser() { | ||
this.userService.deleteUserById(id); | ||
return "refresh"; | ||
} | ||
|
||
public String getAllUser() { | ||
userlist = userService.getAllUser(); | ||
return "user_mgr"; | ||
} | ||
|
||
public String login() { | ||
try { | ||
String username = user.getUsername(); | ||
String password = user.getPassword(); | ||
if (username == null || password == null || username.length() <= 0 || password.length() <= 0) { | ||
return "failed"; | ||
} else { | ||
User user = userService.getUserByUsername(username); | ||
if (user != null) { | ||
if (user.getPassword().equals(password)) { | ||
ActionContext.getContext().getSession().put("user_id", user.getId()); | ||
ActionContext.getContext().getSession().put("username", user.getName()); | ||
return "success"; | ||
} else { | ||
return "failed"; | ||
} | ||
} | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return "error"; | ||
} | ||
return null; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<%-- | ||
Created by IntelliJ IDEA. | ||
User: zhibin.shao | ||
Date: 2017/12/5 | ||
Time: 11:41 | ||
To change this template use File | Settings | File Templates. | ||
--%> | ||
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="gbk" import="java.util.*" %> | ||
<%@ taglib prefix="s" uri="/struts-tags" %> | ||
<% | ||
String path=request.getContextPath(); | ||
String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; | ||
%> | ||
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 4.01 Transitional//EN"> | ||
|
||
<html> | ||
<head> | ||
<base href="<%=basePath%>"> | ||
<title>信息发布系统</title> | ||
<meta http-equiv="pragma" content="no-cache"> | ||
<meta http-equiv="cache-control" content="no-cache"> | ||
<meta http-equiv="expires" content="0"> | ||
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> | ||
<meta http-equiv="description" content="this is my page"> | ||
<link rel="stylesheet" href="style/style_login.css" type="text/css"/> | ||
</head> | ||
<body> | ||
<div id="title"> | ||
<h1 style="font-size: 80px ;font-family: 黑体; color: #FFFFFF;">信息发布系统</h1> | ||
|
||
</div> | ||
<form id="login" method="post" action="<%request.getContextPath();%>/userAction_login.action"> | ||
<input type="text" name="user.username" value="请输入用户名" onfocus="this.value=''"><br/><br/> | ||
<input type="password" name="user.password"/><br/><br/> | ||
<input type="submit" value="登 录"><br/> | ||
</form> | ||
</body> | ||
</html> |
Oops, something went wrong.