作者主页:源码空间站2022
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
管理员角色包含以下功能:
管理员登录,商品种类管理,入库信息管理,出库信息管理,在库信息管理,查看统计信息等功能。
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
技术栈
1. 后端:mysql+Spring+hibernate+spring mcv
2. 前端:HTML+CSS+JavaScript+jsp
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
运行截图
相关代码
用户管理控制器
@Controller("userAction")
@Scope("prototype")
public class UserAction extends BaseAction implements ModelDriven<User>{
private static final long serialVersionUID = 1L;
//==========model==============
private User user;
@Override
public User getModel() {
if(user==null) user = new User();
return user;
}
//==========model==============
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private UserService userService;
//依赖注入 end dao/service/===
//-------------------------华丽分割线---------------------------------------------
//============自定义参数start=============
//============自定义参数end=============
//-------------------------华丽分割线---------------------------------------------
//============文件上传start=======================================================
private File file;
//提交过来的file的名字
private String fileFileName;
//提交过来的file的MIME类型
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
//============文件上传end=========================================================
public String jsonAction() {
// dataMap中的数据将会被Struts2转换成JSON字符串,所以这里要先清空其中的数据
jsonMap.clear();
jsonMap.put("success", true);
return JSON_TYPE;
}
//-------------------------华丽分割线---------------------------------------------//
//=============公=======共=======方=======法==========区=========start============//
/**
* 列表分页查询 and isDelete = 0
*
*/
public String user(){
Map<String,Object> alias = new HashMap<String,Object>();
StringBuffer sb = new StringBuffer();
sb = sb.append("from User where 1=1 ");
if(user !=null && !StringUtils.isEmpty(user.getRealName())){
sb.append(" and realName like :realName ");
alias.put("realName", "%" +user.getRealName()+ "%" );
}
sb = sb.append("order by id desc");
Pager<User> pagers = userService.findByAlias(sb.toString(),alias);
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("Obj", user);
return SUCCESS;
}
/**
* 跳转到添加页面
* @return
*/
public String add(){
return SUCCESS;
}
/**
* 执行添加
* @return
*/
public String exAdd(){
userService.save(user);
ActionContext.getContext().put("url", "/user_user.do");
return "redirect";
}
/**
* 查看详情页面
* @return
*/
public String view(){
User n = userService.getById(user.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
public String my(){
Integer loginId = UserUtils.getLoginId();
if(loginId == null){
ActionContext.getContext().put("url", "/login_ulogin.do");
return "redirect";
}
User n = userService.getById(loginId);
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
/**
* 跳转修改页面
* @return
*/
public String update(){
User n = userService.getById(user.getId());
ActionContext.getContext().put("Obj", n);
return SUCCESS;
}
/**
* 执行修改
* @return
*/
public String exUpdate(){
User n = userService.getById(user.getId());
BeanUtils.copyProperties(user, n, getNullPropertyNames(user));
userService.update(n);
ActionContext.getContext().put("url", "/user_user.do");
return "redirect";
}
public String up(){
Integer loginId = UserUtils.getLoginId();
if(loginId == null){
ActionContext.getContext().put("url", "/login_ulogin.do");
return "redirect";
}
User n = userService.getById(loginId);
n.setPassWord(user.getPassWord());
userService.update(n);
ActionContext.getContext().put("url", "/login_ulogin.do");
return "redirect";
}
/**
* 删除
* @return
*/
public String delete(){
userService.delete(user.getId());
ActionContext.getContext().put("url", "/user_user.do");
return "redirect";
}
//=============公=======共=======方=======法==========区=========end============//
//-------------------------华丽分割线---------------------------------------------//
//=============自=======定=======义=========方=======法==========区=========start============//
//=============自=======定=======义=========方=======法==========区=========end============//
}
如果也想学习本系统,下面领取。关注并回复:102ssh