毕业设计|基于SSM+JSP的家校通管理系统(三)

简介: 毕业设计|基于SSM+JSP的家校通管理系统

毕业设计|基于SSM+JSP的家校通管理系统(二)https://developer.aliyun.com/article/1423937


4.2 网站内容发布

@Controller
@RequestMapping("/introduction")
public class IntroductionController extends BaseController {
  /**
   * 依赖注入 start dao/service/===
   */
  @Autowired
  private IntroductionService introductionService;
  /**
   * 前台查询网页介绍
   * 
   * @param request
   * @param response
   * @return
   */
  @RequestMapping(value = "/queryIntroduction.do")
  public String queryIntroduction(Model model, HttpServletRequest request, HttpServletResponse response) {
    List<Introduction> introductionList=introductionService.listAll();
    model.addAttribute("introductionList", introductionList);
    //存储查询条件
    model.addAttribute("introductionList", introductionList);
    return "introduction/uIntroduction";
  }
  /**
   * 分页查询 返回list对象(通过对象)
   * 
   * @param request
   * @param response
   * @return
   */
  @RequestMapping(value = "/findByObj.do")
  public String findByObj(Introduction introduction, Model model, HttpServletRequest request, HttpServletResponse response) {
    Pager<Introduction> pagers =new Pager<Introduction>();
    if(introduction.getTitle()!=null){
       Map<String, Object> map = getMap();
       map.put("title",introduction.getTitle());
        //模糊查询分页查询
      pagers = introductionService.findByMap(map);
    }else{
    //分页查询
    pagers = introductionService.findByEntity(introduction);
    }
    model.addAttribute("pagers", pagers);
    //存储查询条件
    model.addAttribute("obj", introduction);
    return "introduction/introduction";
  }
  /**
   * 分页查询 返回list对象(通过Map)
   * 
   * @param request
   * @param response
   * @return
   */
  @RequestMapping(value = "/findByMap.do")
  public String findByMap(Introduction introduction, Model model, HttpServletRequest request, HttpServletResponse response) {
    //通过map查询
    Map<String,Object> params = new HashMap<String,Object>();
        if(!isEmpty(introduction.getTitle())){
          params.put("title", introduction.getTitle());
    }
        if(!isEmpty(introduction.getContent())){
          params.put("content", introduction.getContent());
    }
        if(!isEmpty(introduction.getAddTime())){
          params.put("addTime", introduction.getAddTime());
    }
        if(!isEmpty(introduction.getImageUrl())){
          params.put("imageUrl", introduction.getImageUrl());
    }
    //分页查询
    Pager<Introduction> pagers = introductionService.findByMap(params);
    model.addAttribute("pagers", pagers);
    //存储查询条件
    model.addAttribute("obj", introduction);
    return "introduction/introduction";
  }
  /**
   * 跳至添加页面
   * @return
   */
  @RequestMapping(value = "/add.do")
  public String add() {
    return "introduction/add";
  }
  /**
   * 添加执行
   * @return
   */
  @RequestMapping(value = "/exAdd.do")
  public String exAdd(@RequestParam(value = "file", required = false) MultipartFile file, Introduction introduction,HttpServletRequest request, Model model) {
        System.out.println("开始");  
          String path = request.getSession().getServletContext().getRealPath("/")+"upload/";  
          String fileName = file.getOriginalFilename();  
          System.out.println(path);  
          File targetFile = new File("D:/my/upload", fileName);  
          if(!targetFile.exists()){  
              targetFile.mkdirs();  
          }  
          introduction.setImageUrl("\\upload\\"+fileName);
          //保存  
          try {  
              file.transferTo(targetFile);  
          } catch (Exception e) {  
              e.printStackTrace();  
          }  
    introduction.setAddTime(new Date());
    introductionService.insert(introduction);
    return "redirect:/introduction/findByObj.do";
  }
  /**
   * 跳至修改页面
   * @return
   */
  @RequestMapping(value = "/update.do")
  public String update(Integer id,Model model) {
    Introduction obj = introductionService.load(id);
    model.addAttribute("obj",obj);
    return "introduction/update";
  }
  /**
   * 添加修改
   * @return
   */
  @RequestMapping(value = "/exUpdate.do")
  public String exUpdate(@RequestParam(value = "file", required = false) MultipartFile file, Introduction introduction,HttpServletRequest request, Model model) {
     System.out.println("开始");  
          String path = request.getSession().getServletContext().getRealPath("/")+"upload/";  
          String fileName = file.getOriginalFilename();  
          System.out.println(path);  
          File targetFile = new File("D:/my/upload", fileName);  
          if(!targetFile.exists()){  
              targetFile.mkdirs();  
          }
          if(fileName!=null){
            introduction.setImageUrl("\\upload\\"+fileName);
          }
          //保存  
          try {  
              file.transferTo(targetFile);  
          } catch (Exception e) {  
              e.printStackTrace();  
          }  
    introductionService.update(introduction);
    return "redirect:/introduction/findByObj.do";
  }
  /**
   * 删除通过主键
   * @return
   */
  @RequestMapping(value = "/delete.do")
  public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
    //真正删除
    introductionService.deleteById(id);
    //通过参数删除
        //Map<String,Object> params = new HashMap<String,Object>();
    //params.put("id", id);
    //introductionService.deleteBySqId("deleteBySql", params);
    //状态删除
    //Introduction load = introductionService.load(id);
    //load.setIsDelete(1);
    //introductionService.update(load);
    return "redirect:/introduction/findByObj.do";
  }
  // --------------------------------------- 华丽分割线 ------------------------------
  /**
   * 分页查询 返回list json(通过对象)
   * 
   * @param request
   * @param response
   * @return
   */
  @RequestMapping(value = "/findByObj.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
  @ResponseBody
  public String findByObjByEntity(Introduction introduction, Model model, HttpServletRequest request, HttpServletResponse response) {
    //分页查询
    Pager<Introduction> pagers = introductionService.findByEntity(introduction);
    JSONObject jsonObject = JsonUtil2.getJsonObject();
    jsonObject.put("pagers", pagers);
    jsonObject.put("obj", introduction);
    return jsonObject.toString();
  }
  /**
   * 分页查询 返回list json(通过Map)
   * 
   * @param request
   * @param response
   * @return
   */
  @RequestMapping(value = "/findByMap.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
  @ResponseBody
  public String findByMapMap(Introduction introduction, Model model, HttpServletRequest request, HttpServletResponse response) {
    //通过map查询
    Map<String,Object> params = new HashMap<String,Object>();
        if(!isEmpty(introduction.getTitle())){
          params.put("title", introduction.getTitle());
    }
        if(!isEmpty(introduction.getContent())){
          params.put("content", introduction.getContent());
    }
        if(!isEmpty(introduction.getAddTime())){
          params.put("addTime", introduction.getAddTime());
    }
        if(!isEmpty(introduction.getImageUrl())){
          params.put("imageUrl", introduction.getImageUrl());
    }
    //分页查询
    Pager<Introduction> pagers = introductionService.findByMap(params);
    JSONObject jsonObject = JsonUtil2.getJsonObject();
    jsonObject.put("pagers", pagers);
    jsonObject.put("obj", introduction);
    return jsonObject.toString();
  }
  /**
   * ajax 添加
   * @param 
   * @return
   */
  @RequestMapping(value = "/exAdd.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
  @ResponseBody
  public String exAddJson(Introduction introduction, Model model, HttpServletRequest request, HttpServletResponse response) {
    introductionService.insert(introduction);
    JSONObject jsonObject = JsonUtil2.getJsonObject();
    jsonObject.put("message", "添加成功");
    return jsonObject.toString();
  }
  /**
   * ajax 修改
   * @param 
   * @return
   */
  @RequestMapping(value = "/exUpdate.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
  @ResponseBody
  public String exUpdateJson(Introduction introduction, Model model, HttpServletRequest request, HttpServletResponse response) {
    introductionService.update(introduction);
    JSONObject jsonObject = JsonUtil2.getJsonObject();
    jsonObject.put("message", "修改成功");
    return jsonObject.toString();
  }
  /**
   * ajax 删除
   * @return
   */
  @RequestMapping(value = "/delete.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
  @ResponseBody
  public String exDeleteJson(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
    //真正删除
    introductionService.deleteById(id);
    //通过参数删除
        //Map<String,Object> params = new HashMap<String,Object>();
    //params.put("id", id);
    //introductionService.deleteBySqId("deleteBySql", params);
    //状态删除
    //Introduction load = introductionService.load(id);
    //load.setIsDelete(1);
    //introductionService.update(load);
    JSONObject jsonObject = JsonUtil2.getJsonObject();
    jsonObject.put("message", "删除成功");
    return jsonObject.toString();
  }
  /**
   * 单文件上传
   * @param file
   * @param request
   * @param model
   * @return
   */
    @RequestMapping(value = "/saveFile")  
    public String saveFile(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, Model model) {  
        System.out.println("开始");  
        String path = request.getSession().getServletContext().getRealPath("/upload");  
        String fileName = file.getOriginalFilename();  
        System.out.println(path);  
        File targetFile = new File(path, fileName);  
        if(!targetFile.exists()){  
            targetFile.mkdirs();  
        }  
        //保存  
        try {  
            file.transferTo(targetFile);  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
        return "";  
    }  
  /**
   * springMvc多文件上传
   * @param files
   * @param id
   * @return
   */
    @RequestMapping(value = "/saveFiles")
    public String saveFiles(@RequestParam("file") CommonsMultipartFile[] files,Integer id,HttpServletRequest request){
    for(int i = 0;i<files.length;i++){
          System.out.println("fileName---------->" + files[i].getOriginalFilename());
      if(!files[i].isEmpty()){
            int pre = (int) System.currentTimeMillis();
        try {
      //拿到输出流,同时重命名上传的文件
       String filePath = request.getRealPath("/upload");
       File f=new File(filePath);
       if(!f.exists()){
        f.mkdirs();
       }
         String fileNmae=new Date().getTime() + files[i].getOriginalFilename();
         File file=new File(filePath+"/"+pre + files[i].getOriginalFilename());
        if(!file.exists()){
          file.createNewFile();
       }
        files[i].transferTo(file);
         } catch (Exception e) {
        e.printStackTrace();
        System.out.println("上传出错");
       }
      }
    }
    return "";
  }
}

五,相关作品展示

基于Java开发、Python开发、PHP开发、C#开发等相关语言开发的实战项目

基于Nodejs、Vue等前端技术开发的前端实战项目

基于微信小程序和安卓APP应用开发的相关作品

基于51单片机等嵌入式物联网开发应用

基于各类算法实现的AI智能应用

基于大数据实现的各类数据管理和推荐系统

相关文章
|
6月前
|
Java 关系型数据库 MySQL
weixin050高校体育场管理系统+ssm(文档+源码)_kaic
本文针对高校体育场管理系统的开发与实现进行详细介绍。随着经济快速发展,人们对手机软件需求增加,高校体育场管理系统应运而生。系统采用JAVA技术、Mysql数据库和SSM框架等成熟技术,通过分析功能需求、可行性及性能,设计出包含管理员、用户和学生角色的功能模块。系统实现用户注册登录、信息管理等功能,简化传统手工统计模式,提高管理效率,满足用户对信息获取的及时性与准确性需求。
weixin050高校体育场管理系统+ssm(文档+源码)_kaic
|
6月前
|
前端开发 Java 关系型数据库
基于ssm的社区物业管理系统,附源码+数据库+论文+任务书
社区物业管理系统采用B/S架构,基于Java语言开发,使用MySQL数据库。系统涵盖个人中心、用户管理、楼盘管理、收费管理、停车登记、报修与投诉管理等功能模块,方便管理员及用户操作。前端采用Vue、HTML、JavaScript等技术,后端使用SSM框架。系统支持远程安装调试,确保顺利运行。提供演示视频和详细文档截图,帮助用户快速上手。
218 17
|
6月前
|
前端开发 Java 关系型数据库
基于ssm的超市会员(积分)管理系统,附源码+数据库+论文,包安装调试
本项目为简单内容浏览和信息处理系统,具备管理员和员工权限。管理员可管理会员、员工、商品及积分记录,员工则负责积分、商品信息和兑换管理。技术框架采用Java编程语言,B/S架构,前端使用Vue+JSP+JavaScript+Css+LayUI,后端为SSM框架,数据库为MySQL。运行环境为Windows,JDK8+Tomcat8.5,非前后端分离的Maven项目。提供演示视频和详细文档,购买后支持免费远程安装调试。
281 19
|
6月前
|
前端开发 JavaScript Java
[Java计算机毕设]基于ssm的OA办公管理系统的设计与实现,附源码+数据库+论文+开题,包安装调试
OA办公管理系统是一款基于Java和SSM框架开发的B/S架构应用,适用于Windows系统。项目包含管理员、项目管理人员和普通用户三种角色,分别负责系统管理、请假审批、图书借阅等日常办公事务。系统使用Vue、HTML、JavaScript、CSS和LayUI构建前端,后端采用SSM框架,数据库为MySQL,共24张表。提供完整演示视频和详细文档截图,支持远程安装调试,确保顺利运行。
244 17
|
6月前
|
前端开发 Java 关系型数据库
基于ssm的网络直播带货管理系统,附源码+数据库+论文
该项目为网络直播带货网站,包含管理员和用户两个角色。管理员可进行主页、个人中心、用户管理、商品分类与信息管理、系统及订单管理;用户可浏览主页、管理个人中心、收藏和订单。系统基于Java开发,采用B/S架构,前端使用Vue、JSP等技术,后端为SSM框架,数据库为MySQL。项目运行环境为Windows,支持JDK8、Tomcat8.5。提供演示视频和详细文档截图。
153 10
|
6月前
|
前端开发 Java 关系型数据库
基于ssm的台球厅管理系统,附源码+数据库+论文
本项目为新锐台球厅管理系统,支持管理员和会员两种角色。管理员可进行会员管理、台球桌管理、订单管理等;会员可查看台球桌、预约、购买商品等。技术框架基于Java,采用B/S架构,前端使用Vue+HTML+JavaScript+CSS+LayUI,后端使用SSM框架,数据库为MySQL。运行环境为Windows,JDK8+MySQL5.7+Tomcat8.5。提供演示视频及详细文档截图。
|
6月前
|
存储 Java 关系型数据库
ssm150旅游网站的设计与实现+jsp(文档+源码)_kaic
本旅游网站基于现代经济快节奏发展和信息化技术的升级,采用SSM框架、Java语言及Mysql数据库开发。它实现了景点、新闻、酒店、飞机票和火车票管理等功能,帮助管理者高效处理大量数据信息,提升工作效率。系统界面简洁美观,功能布局合理,同时提供了数据安全解决方案,确保信息的安全性和可靠性。该网站不仅提高了事务处理效率,还实现了数据的整体化、规范化与自动化管理。关键词:旅游网站;SSM框架;Mysql;自动化。
|
7月前
|
存储 Java 关系型数据库
ssm026校园美食交流系统(文档+源码)_kaic
本文介绍了基于Java语言和MySQL数据库的校园美食交流系统的设计与实现。该系统采用B/S架构和SSM框架,旨在提高校园美食信息管理的效率与便捷性。主要内容包括:系统的开发背景、目的及内容;对Java技术、MySQL数据库、B/S结构和SSM框架的介绍;系统分析部分涵盖可行性分析、性能分析和功能需求分析;最后详细描述了系统各功能模块的具体实现,如登录、管理员功能(美食分类管理、用户管理等)和前台首页功能。通过此系统,管理员可以高效管理美食信息,用户也能方便地获取和分享美食资讯,从而提升校园美食交流的管理水平和用户体验。
|
Java 数据库连接 Maven
手把手教你如何搭建SSM框架、图书商城系统案例
这篇文章是关于如何搭建SSM框架以及实现一个图书商城系统的详细教程,包括了项目的配置文件整合、依赖管理、项目结构和运行效果展示,并提供了GitHub源码链接。
手把手教你如何搭建SSM框架、图书商城系统案例
|
7月前
|
存储 Java 关系型数据库
ssm064农产品仓库管理系统系统(文档+源码)_kaic
农产品仓库管理系统基于现代经济快速发展和信息化技术的升级,采用SSM框架、Java语言及Mysql数据库开发。系统旨在帮助管理者高效处理大量数据信息,提升事务处理效率,实现数据管理的科学化与规范化。该系统涵盖物资基础数据管理、出入库订单管理等功能,界面简洁美观,符合用户操作习惯,并提供数据安全解决方案,确保信息的安全性和可靠性。通过自动化和集中处理,系统显著提高了仓库管理的效率和准确性。

相关课程

更多