基于javaweb+jsp的火车票预订系统(java+JDBC+JSP+Servlet+html+mysql)
一、项目运行
环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP + Servlert + html+ css + Javascript + JQuery + Ajax 等等;
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
* @return
*/
@RequestMapping("changePassword.do")
@ResponseBody
public Map changePassword(String oldPassword, String newPassword,
String rePassword, HttpSession httpSession){
HashMap map = new HashMap();
if (newPassword.equals(rePassword)){
SystemManager admin = (SystemManager) httpSession.getAttribute("admin");
String encodeByMD5 = MD5Utils.encodeByMD5(oldPassword);
if (encodeByMD5.equals(admin.getSmPassword())){
String newPasswords = MD5Utils.encodeByMD5(newPassword);
admin.setSmPassword(newPasswords);
userInforService.updateSystemManagePassword(admin.getSmId(),admin);
map.put("type","success");
map.put("msg","密码修改成功");
return map;
}else{
map.put("type","error");
map.put("msg","原密码错误");
return map;
//查找条件,一定要紧跟在startPage后
List salaryList = userInforService.getEmployeeSalaryList(eId, year);
PageInfo pageResult = new PageInfo(salaryList);
//设置前台需要的数据
EmployeeSalaryVO employeeSalaryVO = new EmployeeSalaryVO();
employeeSalaryVO.setCode(0);
employeeSalaryVO.setMsg("");
employeeSalaryVO.setCount((int) pageResult.getTotal());
employeeSalaryVO.setData(pageResult.getList());
return employeeSalaryVO;
* @param httpSession
* @param username
* @param password
* @param identifyingcode
* @return
*/
@RequestMapping(value = "/adminLogin.do")
@ResponseBody
public Message adminLogin(HttpSession httpSession, String username,
String password, String identifyingcode)
{
if(StringUtils.isEmpty(username)) {
return Message.error("请填写账号");
}
@PostMapping("/query")
@ResponseBody
public Map query(@RequestBody User user) {
List list = userService.query(user);
Integer count = userService.count(user);
return MapControl.getInstance().success().page(list, count).getMap();
}
//跳转列表页面
@GetMapping("/list")
public String list() {
return "user/list";
}
}
个人中心Controller:
@Controller
public class UserInforController {
@Autowired
modelMap.addAttribute("user", user);
return "user/edit";
}
//查询所有
@PostMapping("/query")
@ResponseBody
public Map query(@RequestBody User user) {
List list = userService.query(user);
Integer count = userService.count(user);
return MapControl.getInstance().success().page(list, count).getMap();
}
//跳转列表页面
@GetMapping("/list")
public String list() {
public Mapdelete(String ids) { int result = userService.delete(ids); if (result <= 0) { return MapControl.getInstance().error().getMap(); } return MapControl.getInstance().success().getMap(); } @PostMapping("/edit") @ResponseBody public Map edit(@RequestBody User user) { if(StringUtils.isEmpty(user.getUserName())){ return MapControl.getInstance().error("请填写用户名").getMap(); } if(StringUtils.isEmpty(user.getName())){ return MapControl.getInstance().error("请填写名称").getMap(); }
if(userInforService.updateEmploueeById(id,employee)<=0) {
return Message.error("修改信息失败");
}
return Message.success();
}
@RequestMapping("employeeSalaryList.do")
@ResponseBody
public EmployeeSalaryVO findSelective(
@RequestParam(value="page", defaultValue="1")int pageNum,
@RequestParam(value="limit", defaultValue="10") int limit,
@PostMapping("/delete")
@ResponseBody
public Map delete(String ids) {
int result = userService.delete(ids);
if (result <= 0) {
return MapControl.getInstance().error().getMap();
}
return MapControl.getInstance().success().getMap();
}
@RequestMapping("changeEmployeePassword.do")
@ResponseBody
}
个人中心Controller:
@Controller
public class UserInforController {
@Autowired
private UserInforServiceImpl userInforService = null;
@RequestMapping("changePassword.do")
@ResponseBody
public Map changePassword(String oldPassword, String newPassword,
String rePassword, HttpSession httpSession){
HashMap map = new HashMap();
if (newPassword.equals(rePassword)){
@PostMapping("/delete/{id}")
@ResponseBody
public Map delete(@PathVariable("id") Integer id) {
int result = userService.delete(id);
if (result <= 0) {
return MapControl.getInstance().error().getMap();
}
return MapControl.getInstance().success().getMap();
}
//批量删除
@PostMapping("/delete")
@ResponseBody
public Map delete(String ids) {
PageHelper.startPage(pageNum,limit);
//查找条件,一定要紧跟在startPage后
List salaryList = userInforService.getEmployeeSalaryList(eId, year);
PageInfo pageResult = new PageInfo(salaryList);
//设置前台需要的数据
EmployeeSalaryVO employeeSalaryVO = new EmployeeSalaryVO();
employeeSalaryVO.setCode(0);
employeeSalaryVO.setMsg("");
employeeSalaryVO.setCount((int) pageResult.getTotal());
employeeSalaryVO.setData(pageResult.getList());
return employeeSalaryVO;
}
}
管理员和员工登陆控制:
@Controller
return MapControl.getInstance().success().getMap();
}
//批量删除
@PostMapping("/delete")
@ResponseBody
public Map delete(String ids) {
int result = userService.delete(ids);
if (result <= 0) {
return MapControl.getInstance().error().getMap();
}
return MapControl.getInstance().success().getMap();
}
用户管理操作:
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@GetMapping("/add")
public String create() {
return "user/add";
}
@RequestMapping(value = "/employeeLogin.do")
@ResponseBody
public Message employeeLogin(HttpSession httpSession, String username,
}
}else{
map.put("type","error");
map.put("msg","两次密码不一致");
return map;
}
}
@RequestMapping("inforEmployee.do")
public @ResponseBody EmployeeCustomVo getInforEmployee(HttpSession httpSession){
Integer id = (Integer) httpSession.getAttribute("employeeId");
EmployeeCustomVo employeeCustomVo = userInforService.getInforEmployee(id);
return employeeCustomVo;
@RequestMapping("/")
public String getLoginPage(){
return "employee/login.html";
}
// 获取管理员登陆界面
@RequestMapping("/admin.do")
public String getAdminLoginPage(HttpServletRequest request){
String realPath = request.getServletContext().getRealPath("/");
request.getSession().setAttribute("realPath", realPath);
return "admin/adminLogin.html";
}
@RequestMapping(value = "/employeeLogin.do")
@ResponseBody
* @return
*/
@GetMapping("/add")
public String create() {
return "user/add";
}
@PostMapping("/add")
@ResponseBody
public Map add(@RequestBody User user) {
if(StringUtils.isEmpty(user.getUserName())){
return MapControl.getInstance().error("请填写用户名").getMap();
}
if(StringUtils.isEmpty(user.getName())){
return MapControl.getInstance().error("请填写名称").getMap();
}
if(StringUtils.isEmpty(user.getUserPwd())){
return MapControl.getInstance().error("请填写密码").getMap();
}
@RequestMapping(value = "/changeCode.do")
@ResponseBody
public void getIdentifyingCode(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
// 验证码存储在session的identifyingCode,属性中
CaptchaUtil.outputCaptcha(request, response);
}
// 获取员工登陆界面
@RequestMapping("/")
public String getLoginPage(){
return "employee/login.html";
}
// 获取管理员登陆界面
@RequestMapping("/admin.do")
public String getAdminLoginPage(HttpServletRequest request){
String realPath = request.getServletContext().getRealPath("/");
request.getSession().setAttribute("realPath", realPath);
管理员和员工登陆控制:
@Controller
public class LoginController {
@Autowired
private LoginServiceImpl loginService = null;
@RequestMapping(value = "/changeCode.do")
@ResponseBody
}
}
@Controller
public class LoginController {
@Autowired
private LoginServiceImpl loginService = null;
@PostMapping("/delete/{id}")
@ResponseBody
public Map delete(@PathVariable("id") Integer id) {
int result = userService.delete(id);
if (result <= 0) {
return MapControl.getInstance().error().getMap();
适用
课程设计,大作业,毕业设计,项目练习,学习演示等



