开发语言:Java
框架:ssm
技术:JSP
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7(一定要5.7版本)
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
后台路径地址:localhost:8080/项目名称/jsp/login.jsp
前台路径地址:localhost:8080/项目名称/front/index.jsp (无前台不需要输入)
管理员账号:admin
管理员密码:admin
2.1开发工具
系统是用JSP技术编写的,系统使用的环境变量为jdk1.8[4]。编译器用的是Eclipse,系统采用SSM框架技术,采用Maven管理jar包,后台数据来自数据库mysql。
2.2 JSP技术介绍
JSP技术是日常生活中广泛使用、十分普遍的语言工具。该技术的开发过程经历了重重曲折,但一经问世,就造成了巨大的影响。JSP技术对于所有的JAVA类,都能够对其进行操作,方便快捷,减少了很多JAVA开发中的麻烦。当JSP技术与JAVA Beans类结合在一起使用时,就能够将显示逻辑和内容分离开。并且在Web网页这一块,他可以利用自身的特有属性,提高网页的执行速度,对于Web网页的开发和使用具有非常的帮助推动作用。所有的脚本都在伺服器端执行,而JSP引擎则会根据用户所提出的要求做出说明,然后产生脚本程序和JSP标识,最后再通过HTML/XML界面把结果反馈给客户端。所以,当开发人员亲自设计了一个网页的基本格式和HTML/XML标识时,就完全可以采用JSP技术了。
是根据电子产品交易系统的实际需要和对功能模块的实现,于是采用JSP技术是最满足开发运行条件的,同时由于JSP的可扩展性比较良好,所以电子产品交易系统在后期应用过程中能够进一步的对系统功能加以扩充完善,从而使管理系统更完整,更便捷的满足实际需要。
2.3 Tomcat服务器简介
Tomcat是Apache公司的研发并发布的产品。 Tomcat 是一个小型的轻量级应用服务器, 在中小型系统和并发访问 用户不是很多的场合下被普遍使用。它还具有很强的稳定性。Tomcat是嵌入式的,不需要进行war文件的部署。并且,它也同时简化了Maven的配置。简化了程序员的开发步骤。
2.4 SSM框架
SSM是当前主流的Java EE轻量级开源框架集合,由Mybatis、Spring、Spring MVC三个框架组合组合而成,采用标准的MVC模式,具有速度快、性能高且稳定、配置简单等特点,适用于搭建各种大型的企业级应用系统。SSM执行逻辑总体可划分为表示层(View)、控制层(Controller)、业务逻辑层(Service)和数据访问层(DAO)层。
2.5 MySQL数据库技术简介
MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,属于Oracle旗下产品。MySQL谁最流行的关系型数据库管理系统之一,在Web应用方面,MySQL是最好的RDBMS(关系型数据库管理系统)应用软件之一。
MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。MySQL软件采用了双授权政策,分为社区版和商业版,由于其体积小,速度快,总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择MySQL作为网站数据库。
package com.controller;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UsersEntity;
import com.service.TokenService;
import com.service.UsersService;
import com.utils.CommonUtil;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;
/**
* 登录相关
*/
@RequestMapping("users")
@RestController
public class UsersController{
@Autowired
private UsersService userService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
UsersEntity user = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
if(user==null || !user.getPassword().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody UsersEntity user){
// ValidatorUtils.validateEntity(user);
if(userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
userService.insert(user);
return R.ok();
}
/**
* 退出
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
UsersEntity user = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
if(user==null) {
return R.error("账号不存在");
}
user.setPassword("123456");
userService.update(user,null);
return R.ok("密码已重置为:123456");
}
/**
* 列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,UsersEntity user){
EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>();
PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/list")
public R list( UsersEntity user){
EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>();
ew.allEq(MPUtil.allEQMapPre( user, "user"));
return R.ok().put("data", userService.selectListView(ew));
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
UsersEntity user = userService.selectById(id);
return R.ok().put("data", user);
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
UsersEntity user = userService.selectById(id);
return R.ok().put("data", user);
}
/**
* 保存
*/
@PostMapping("/save")
public R save(@RequestBody UsersEntity user){
// ValidatorUtils.validateEntity(user);
if(userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
userService.insert(user);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody UsersEntity user){
// ValidatorUtils.validateEntity(user);
UsersEntity u = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername()));
if(u!=null && u.getId()!=user.getId() && u.getUsername().equals(user.getUsername())) {
return R.error("用户名已存在。");
}
userService.updateById(user);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
userService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}
validationQuery=SELECT 1
jdbc_url=jdbc:mysql://127.0.0.1:3306/jspmechmf?useUnicode=true&characterEncoding=UTF-8&tinyInt1isBit=false
jdbc_username=root
jdbc_password=123456
#jdbc_url=jdbc:sqlserver://127.0.0.1:1433;DatabaseName=jspmechmf
#jdbc_username=sa
#jdbc_password=123456