基于javaweb的流浪猫狗救助管理系统(java+ssm+jsp+bootstrap+jquery+mysql)

基于javaweb的流浪猫狗救助管理系统(java+ssm+jsp+bootstrap+jquery+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

20220519000554

20220519000555

20220519000556

20220519000557

20220519000558

20220519000600

基于javaweb+SSM的流浪猫狗救助管理系统(java+SSM+JSP+bootstrap+jQuery+mysql)

项目介绍

流浪猫狗救助管理系统。该项目分为前后台; 前台主要功能包括:会员的注册登陆,流浪猫狗知识,领养中心,团队活动,流浪宠物详情,申请领养等; 后台主要功能包括:管理员的用户信息管理,流浪猫狗信息管理,管理员信息管理,领养管理,评论管理,团队活动管理,志愿者申请信息管理,同意/不同意领养信息列表等

环境需要

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.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目  6.数据库:MySql 8.0版本;

技术栈

  1. 后端:Spring SpringMVC MyBatis 2. 前端:JSP+bootstrap+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 将项目中db.properties配置文件中的数据库配置改为自己的配置 3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 4. 运行项目, 前台地址 http://localhost:8080/web/animal/index.jsp 后台地址 http://localhost:8080/web/animal/admin/login.jsp

后台管理员控制层:

@Controller

@RequestMapping(“admin/user”)

public class adminUserController {

@Autowired

UserService userService;

@Autowired

PostMapper postMapper;

@Autowired

ShareMapper shareMapper;

@Autowired

SponsorMapper sponsorMapper;

@GetMapping(“”)

public String write(Model model, HttpSession session,

@RequestParam(value = “page”, defaultValue = “1”) int page,

@RequestParam(value = “limit”, defaultValue = “12”) int limit){

model.addAttribute(“info”,userService.queryUserAll(page,limit));

return “admin/admin_user”;

@GetMapping(“delete”)

public String deleteUser(@RequestParam(“userId”) int userId){

User user=userService.queryUserById(userId);

if(user.getUserPhone().equals(“1111”)){

return “redirect:/admin/user”;

postMapper.deletePostByPhone(user.getUserPhone());

shareMapper.deleteShareByPhone(user.getUserPhone());

sponsorMapper.deleteSponsorByPhone(user.getUserPhone());

userService.deleteUser(userId);

return “redirect:/admin/user”;

详情管理控制层:

@Controller

@RequestMapping(“details”)

public class detailsController {

@Autowired

IndexService indexService;

@Autowired

NoticeService noticeService;

@Autowired

DetailsService detailsService;

@Autowired

PostService postService;

@Autowired

SponsorService sponsorService;

@Autowired

ShareService shareService;

@Autowired

CommentMapper commentMapper;

@Autowired

HttpSession session;

@Autowired

ReportService reportService;

@Autowired

SentenceService sentenceService;

@GetMapping

public String index(Model model,Integer id,String status){

int i=-1;

if(status.equals(IndexFrom.Post.getDesc())){

i=0;

}else if(status.equals(IndexFrom.Share.getDesc())){

i=1;

} else if(status.equals(IndexFrom.Sponsor.getDesc())){

i=2;

session.setAttribute(CatConst.USER_DETAILS_STATUS,i);

session.setAttribute(CatConst.USER_DETAILS_CODE,id);

model.addAttribute(“comments”,detailsService.findComment(i,id));

detailsService.addCount(id,i);

model.addAttribute(“count”,commentMapper.queryCount1(id,i));

model.addAttribute(“recommends”,detailsService.findRecommends(i));

IndexVo info=detailsService.findDetails(id,i);

model.addAttribute(“info”,info);

model.addAttribute(“url”,TitleUtil.getUrl());

List indexMax=indexService.findMaxCount();

List notices=noticeService.queryNotice();

model.addAttribute(“notices”,notices);

model.addAttribute(“indexMax”,indexMax);

Sentence sentence=sentenceService.findSentence();

model.addAttribute(“sentence”,sentence);

return “details”;

@PostMapping(“interceptor/addComment”)

public String comment(String comment,Model model){

int i= (int) session.getAttribute(CatConst.USER_DETAILS_STATUS);

int id= (int) session.getAttribute(CatConst.USER_DETAILS_CODE);

User user= (User) session.getAttribute(“user_session”);

Comment comment1=new Comment();

comment1.setCommentContent(comment);

comment1.setCommentPhone(user.getUserPhone());

comment1.setCommentCreatetime(new Date());

comment1.setCommentPsId(id);

comment1.setCommentSource(i);

commentMapper.addComment(comment1);

model.addAttribute(“comments”,detailsService.findComment(i,id));

detailsService.addCount(id,i);

model.addAttribute(“count”,commentMapper.queryCount1(id,i));

model.addAttribute(“recommends”,detailsService.findRecommends(i));

IndexVo info=detailsService.findDetails(id,i);

model.addAttribute(“info”,info);

List indexMax=indexService.findMaxCount();

List notices=noticeService.queryNotice();

model.addAttribute(“notices”,notices);

model.addAttribute(“indexMax”,indexMax);

Sentence sentence=sentenceService.findSentence();

model.addAttribute(“sentence”,sentence);

model.addAttribute(“url”,TitleUtil.getUrl());

return “details”;

@PostMapping(“interceptor/report”)

public String report(String reason,Model model){

int i= (int) session.getAttribute(CatConst.USER_DETAILS_STATUS);

int id= (int) session.getAttribute(CatConst.USER_DETAILS_CODE);

User user= (User) session.getAttribute(“user_session”);

if(reason.equals(“”)==false){

Report report=new Report();

report.setReportUser(user.getUserNickname());

report.setReportCreatetime(new Date());

report.setReportContent(reason);

if(i==0){

report.setReportFrom(“启示”);

}if(i==1){

report.setReportFrom(“分享”);

}if(i==2){

report.setReportFrom(“赞助”);

report.setReportFromId(id);

reportService.addReport(report);

model.addAttribute(“comments”,detailsService.findComment(i,id));

detailsService.addCount(id,i);

model.addAttribute(“recommends”,detailsService.findRecommends(i));

IndexVo info=detailsService.findDetails(id,i);

model.addAttribute(“info”,info);

List indexMax=indexService.findMaxCount();

List notices=noticeService.queryNotice();

model.addAttribute(“notices”,notices);

model.addAttribute(“indexMax”,indexMax);

Sentence sentence=sentenceService.findSentence();

model.addAttribute(“sentence”,sentence);

model.addAttribute(“url”,TitleUtil.getUrl());

return “details”;

登录管理控制层:

@Controller

@RequestMapping(“”)

public class loginController {

@Autowired

UserService userService;

@GetMapping(value = {“/login”})

public String login(){

return “login”;

@GetMapping(“reBack”)

public String reBack(HttpSession session){

String url= (String) session.getAttribute(“user_old_url”);

if(url==null){

url=“/”;

return “redirect:”+url;

@GetMapping(value = {“login1”})

public String login1(@RequestParam(value =“userUrl”) String userUrl,HttpSession session){

if(userUrl!=null){

session.setAttribute(CatConst.USER_SESSION_URL,userUrl);

return “login”;

@PostMapping(“login/getLogin”)

@ResponseBody

public LoginResult getLogin(@RequestParam(value =“phone”) String phone,

@RequestParam(value =“password”) String password, HttpSession session) {

User user = userService.queryByPhone(phone);

if(user!=null){

if(user.getUserPassword().equals(MD5Util.getMD5(password))){

session.setAttribute(CatConst.USER_SESSION_KEY, user);

if(user.getUserPhone().equals(“1111”)){

session.setAttribute(CatConst.USER_SESSION_administrators, user.getUserPhone());

return new LoginResult(true, “登录成功”);

}else {

return new LoginResult(false, “密码错误”);

}else {

return new LoginResult(false, “用户名错误”);

@PostMapping(“/login/register”)

@ResponseBody

public JsonResult register(User user,@RequestParam(value =“userCode”) String userCode,HttpSession session){

String code=session.getAttribute(CatConst.USER_SESSION_CODE).toString();

if(code.equals(userCode)){

if(userService.queryByPhone(user.getUserPhone())!=null){

return new JsonResult(false, “电话号码已经注册!”);

}else {

user.setUserPassword(MD5Util.getMD5(user.getUserPassword()));

user.setUserCreatetime(new Date());

user.setUserUrl(TitleUtil.getUrl());

int i=userService.addUser(user);

if(i==1){

session.removeAttribute(CatConst.USER_SESSION_CODE);

return new JsonResult(true, “注册成功!”);

}else {

return new JsonResult(false, “注册失败!”);

}else {

return new JsonResult(false, “验证码错误!”);

@PostMapping(“login/updatePassword”)

@ResponseBody

public JsonResult updatePassword(@RequestParam(value =“userPhone”) String userPhone,

@RequestParam(value =“userCode”) String userCode,

@RequestParam(value =“userPassword”) String userPassword,HttpSession session){

String code=session.getAttribute(CatConst.USER_SESSION_CODE).toString();

if(code.equals(userCode)){

int i=userService.updateUserPhone(MD5Util.getMD5(userPassword),userPhone);

if(i==1){

session.removeAttribute(CatConst.USER_SESSION_CODE);

return new JsonResult(true, “密码更新成功!”);

}else {

return new JsonResult(false, “密码更新失败!”);

}else {

return new JsonResult(false, “验证码错误!”);

@PostMapping(“login/getCode”)

@ResponseBody

public JsonResult getCode(@RequestParam(value =“userPhone”) String userPhone,HttpSession session){

DuanxinService duanxinService=new DuanxinService();

// int code=duanxinService.duanXin(userPhone);

session.setAttribute(CatConst.USER_SESSION_CODE,“1234”);

return new JsonResult(true,“发送成功”);

// 有时,一些网站的部分操作需要登录才能访问。如果跳转到登录界面登录成功后,怎样才能返回到登录之前的界面呢?

// 很简单,我们在代码部分中添加一部分很少的代码即可。在从一个页面跳转到登录界面之前的代码,我们用session保

// 存当前界面的url信息,在跳转到登录界面,登录成功后的代码中,判读是否有这个session信息,如果有,则跳转到

// session所存的url,记住跳转前清空这个session,否则在未关闭浏览器重新登录时可能又会跳到session中所存储url的界面。


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的Java Web项目的实现,主要包括登录、注册、用户信息管理和商品信息管理等功能: 1. 登录页面(login.jsp): ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>登录页面</title> </head> <body> <h1>用户登录</h1> <form action="loginServlet" method="post"> <label>用户名:</label> <input type="text" name="username"><br> <label>密码:</label> <input type="password" name="password"><br> <input type="submit" value="登录"> </form> </body> </html> ``` 2. 登录Servlet(LoginServlet.java): ```java @WebServlet("/loginServlet") public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; public LoginServlet() { super(); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String username = request.getParameter("username"); String password = request.getParameter("password"); // 验证用户名和密码是否正确 if(username.equals("admin") && password.equals("123456")) { // 登录成功,将用户信息保存到Session中 HttpSession session = request.getSession(); session.setAttribute("username", username); // 跳转到用户信息管理页面 response.sendRedirect("userList.jsp"); } else { // 登录失败,返回登录页面并提示错误信息 request.setAttribute("errorMsg", "用户名或密码错误!"); request.getRequestDispatcher("login.jsp").forward(request, response); } } } ``` 3. 用户信息管理页面(userList.jsp): ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>用户信息管理</title> </head> <body> <h1>用户信息管理</h1> <p>欢迎您,<%=session.getAttribute("username")%>!</p> <a href="logoutServlet">退出登录</a> <hr> <table border="1"> <tr> <th>用户名</th> <th>密码</th> <th>操作</th> </tr> <tr> <td>admin</td> <td>123456</td> <td> <a href="#">编辑</a> <a href="#">删除</a> </td> </tr> </table> </body> </html> ``` 4. 退出登录Servlet(LogoutServlet.java): ```java @WebServlet("/logoutServlet") public class LogoutServlet extends HttpServlet { private static final long serialVersionUID = 1L; public LogoutServlet() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 销毁Session并跳转到登录页面 request.getSession().invalidate(); response.sendRedirect("login.jsp"); } } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值