• 大小: 10.71MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-07
  • 语言: 其他
  • 标签: ssm  spring  增删改查  

资源简介

本项目适合初学者,框架集合后做的ssm整合,支持增删改查,模糊查询,有bug敬请指正

资源截图

代码片段和文件信息

package com.mybatis.demo.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.mybatis.demo.entity.PageBean;
import com.mybatis.demo.entity.User;
import com.mybatis.demo.service.UserService;
import com.mybatis.demo.util.ResponseUtil;

import net.sf.json.JSONArray;
import net.sf.json.JSONobject;

@Controller
@RequestMapping(“user“)
public class UserController {

@Autowired
private UserService userService;

@RequestMapping(“listall“)
public String getAll(@RequestParam(value=“page“required=false)String page@RequestParam(value=“rows“required=false)String rowsHttpServletResponse responseUser user) throws Exception{
PageBean pageBean=new PageBean(Integer.parseInt(page)Integer.parseInt(rows));
Mapject> map=new HashMapject>();
map.put(“name“ user.getName());
map.put(“start“ pageBean.getStart());
map.put(“size“ pageBean.getPageSize());
List userList=userService.getUsers(map);
Long total=userService.getTotalUser();
JSONobject result=new JSONobject();
JSONArray jsonArray=JSONArray.fromobject(userList);
result.put(“rows“ jsonArray);
result.put(“total“ total);
ResponseUtil.write(response result);
return null;
}
@RequestMapping(“list“)
public String list(){
return “list“;
}

/**
 * 添加用户
 * @param customer
 * @param response
 * @return
 * @throws Exception
 */
@RequestMapping(“/save“)
public String save(User userHttpServletResponse response)throws Exception{
int resultTotal=0; // 操作的记录条数
if(user.getId()==null){
resultTotal=userService.addUser(user);
}else{
resultTotal=userService.updateUser(user);
}
JSONobject result=new JSONobject();
if(resultTotal>0){ // 执行成功
result.put(“success“ true);
}else{
result.put(“success“ false);
}
ResponseUtil.write(response result);
return null;
}

/**
 * 删除用户
 * @param ids
 * @param response
 * @return
 * @throws Exception
 */
@RequestMapping(“/delete“)
public String delete(@RequestParam(value=“ids“)String idsHttpServletResponse response)throws Exception{
JSONobject result=new JSONobject();
String []idsStr=ids.split(““);
for(int i=0;i userService.deleteUser(Integer.parseInt(idsStr[i]));
}
result.put(“success“ true);
ResponseUtil.write(response result);
return null;
}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2629  2018-01-10 17:05  mybatis-spring-smvc\.classpath

     文件       1127  2018-01-10 17:00  mybatis-spring-smvc\.project

     文件        364  2018-01-10 17:10  mybatis-spring-smvc\.settings\org.eclipse.jdt.core.prefs

     文件        584  2018-01-10 17:10  mybatis-spring-smvc\.settings\org.eclipse.wst.common.component

     文件        219  2018-01-10 17:10  mybatis-spring-smvc\.settings\org.eclipse.wst.common.project.facet.core.xml

     文件        533  2018-01-10 17:00  mybatis-spring-smvc\.springBeans

     文件       2137  2018-01-10 17:00  mybatis-spring-smvc\build\classes\application.xml

     文件       3940  2018-01-12 13:56  mybatis-spring-smvc\build\classes\com\mybatis\demo\controller\UserController.class

     文件        488  2018-01-12 13:56  mybatis-spring-smvc\build\classes\com\mybatis\demo\dao\UserMapper.class

     文件        835  2018-01-12 13:56  mybatis-spring-smvc\build\classes\com\mybatis\demo\entity\PageBean.class

     文件       1402  2018-01-12 13:56  mybatis-spring-smvc\build\classes\com\mybatis\demo\entity\User.class

     文件       1349  2018-01-12 13:56  mybatis-spring-smvc\build\classes\com\mybatis\demo\service\UserService.class

     文件        959  2018-01-12 13:56  mybatis-spring-smvc\build\classes\com\mybatis\demo\util\ResponseUtil.class

     文件        103  2018-01-10 17:00  mybatis-spring-smvc\build\classes\db.properties

     文件       1292  2018-01-10 17:00  mybatis-spring-smvc\build\classes\mybatis\mapper\UserMapper.xml

     文件        277  2018-01-10 17:00  mybatis-spring-smvc\build\classes\mybatis.xml

     文件       2137  2018-01-10 17:00  mybatis-spring-smvc\conf\application.xml

     文件        103  2018-01-10 17:00  mybatis-spring-smvc\conf\db.properties

     文件       1292  2018-01-10 17:00  mybatis-spring-smvc\conf\mybatis\mapper\UserMapper.xml

     文件        277  2018-01-10 17:00  mybatis-spring-smvc\conf\mybatis.xml

     文件       2802  2018-01-10 17:00  mybatis-spring-smvc\src\com\mybatis\demo\controller\UserController.java

     文件        490  2018-01-11 15:17  mybatis-spring-smvc\src\com\mybatis\demo\dao\UserMapper.java

     文件        632  2018-01-10 17:00  mybatis-spring-smvc\src\com\mybatis\demo\entity\PageBean.java

     文件        704  2018-01-10 17:00  mybatis-spring-smvc\src\com\mybatis\demo\entity\User.java

     文件        821  2018-01-10 17:00  mybatis-spring-smvc\src\com\mybatis\demo\service\UserService.java

     文件        396  2018-01-10 17:00  mybatis-spring-smvc\src\com\mybatis\demo\util\ResponseUtil.java

     文件       3646  2018-01-10 17:00  mybatis-spring-smvc\ssm整合步骤.txt

     文件      93639  2018-01-10 17:00  mybatis-spring-smvc\WebContent\highcharts4\jquery-1.8.3.min.js

     文件       5314  2018-01-10 17:00  mybatis-spring-smvc\WebContent\highcharts4\js\adapters\standalone-framework.js

     文件      12516  2018-01-10 17:00  mybatis-spring-smvc\WebContent\highcharts4\js\adapters\standalone-framework.src.js

............此处省略712个文件信息

评论

共有 条评论