资源简介

使用ssm即spring springmvc mybaties 写了一个增上改查 数据库使用的mysql 里面包含sql文件 运行即可跑通 适合初学者来学习ssm框架 使用技术包括ssm框架的整合+jquery+ajax+json传值 没有bug 方便大家学习,如有疑问欢迎联系作者

资源截图

代码片段和文件信息

package com.baidu.action;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

import org.apache.logging.log4j.core.config.JSONConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.baidu.pojo.Users;
import com.baidu.service.UserService;
import com.baidu.util.PageUtil;

@Controller
public class ViewAction {
@Autowired
private UserService userService;
@RequestMapping(“/list.action“)
public String list(HttpServletRequest requestHttpServletResponse responseUsers users) throws UnsupportedEncodingException{
//Users users = new Users();
request.setCharacterEncoding(“UTF-8“);
response.setCharacterEncoding(“UTF-8“);
String currentPage = request.getParameter(“currentPage“);
int pageSize = 5;
int count = userService.getCount();
PageUtil pageUtil = new PageUtil(currentPage pageSize count);
request.setAttribute(“pageUtil“ pageUtil);
users.setI((pageUtil.getCurrentPage()-1)*pageSize);
users.setJ(pageSize);
String name = users.getName();
if(name==null){
name=““;
}
users.setName(name);
List list=userService.getUserList1(users);
List list2=userService.getDeptList();
request.setAttribute(“deptList“ list2);
request.setAttribute(“userList“ list);
return “list“;
}
@RequestMapping(“/toUpdate.action“)
public void toUpdate(HttpServletRequest requestHttpServletResponse response) throws IOException{
response.setCharacterEncoding(“utf-8“);
String id = request.getParameter(“id“);
System.out.println(id);
List list = userService.getListById(Integer.parseInt(id));
JSONArray json = JSONArray.fromobject(list);
response.getWriter().write(json.toString());

}

@RequestMapping(“/toUpdate1.action“)
public void toUpdate1(HttpServletRequest requestHttpServletResponse response) throws IOException{
response.setCharacterEncoding(“utf-8“);
String id = request.getParameter(“id“);
System.out.println(id);
Users users=userService.getUsersById(Integer.parseInt(id));
JSONobject jsonobject = JSONobject.fromobject(users);
response.getWriter().write(jsonobject.toString());

}

@RequestMapping(“/update.action“)
public String update(HttpServletRequest requestHttpServletResponse responseUsers users) throws UnsupportedEncodingException{
request.setCharacterEncoding(“UTF-8“);
response.setCharacterEncoding(“UTF-8“);
System.out.println(users.getName());
System.out.println(users.getDid());
System.out.println(users.getId());
userService.Update(users);
String currentPage = request.getParameter(“currentPage“);
int pageSize = 5;
int count = userService.getCount();

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        1958  2016-12-04 14:19  hib_demo.sql
     目录           0  2016-12-04 14:19  ssm\
     文件        3745  2016-12-04 14:19  ssm\.classpath
     目录           0  2016-12-04 14:19  ssm\.myeclipse\
     文件         282  2016-12-04 14:19  ssm\.mymetadata
     文件        1746  2016-12-04 14:19  ssm\.project
     目录           0  2016-12-04 14:19  ssm\.settings\
     文件         500  2016-12-04 14:19  ssm\.settings\.jsdtscope
     文件         168  2016-12-04 14:19  ssm\.settings\com.genuitec.eclipse.core.prefs
     文件         364  2016-12-04 14:19  ssm\.settings\org.eclipse.jdt.core.prefs
     文件         522  2016-12-04 14:19  ssm\.settings\org.eclipse.wst.common.component
     文件         252  2016-12-04 14:19  ssm\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2016-12-04 14:19  ssm\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2016-12-04 14:19  ssm\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2016-12-04 14:19  ssm\conf\
     文件        2812  2016-12-04 14:19  ssm\conf\beans.xml
     文件         125  2016-12-04 14:19  ssm\conf\jdbc.properties
     文件         279  2016-12-04 14:19  ssm\conf\log4j.properties
     文件        1154  2016-12-04 14:19  ssm\conf\sqlMapConfig.xml
     目录           0  2016-12-04 14:19  ssm\src\
     目录           0  2016-12-04 14:19  ssm\src\com\
     目录           0  2016-12-04 14:19  ssm\src\com\baidu\
     目录           0  2016-12-04 14:19  ssm\src\com\baidu\action\
     文件        4565  2016-12-04 14:19  ssm\src\com\baidu\action\ViewAction.java
     目录           0  2016-12-04 14:19  ssm\src\com\baidu\dao\
     文件        3921  2016-12-04 14:19  ssm\src\com\baidu\dao\UserDao.java
     目录           0  2016-12-04 14:19  ssm\src\com\baidu\mapper\
     文件         840  2016-12-04 14:19  ssm\src\com\baidu\mapper\DeptMapper.java
     文件        6048  2016-12-04 14:19  ssm\src\com\baidu\mapper\DeptMapper.xml
     文件        1026  2016-12-04 14:19  ssm\src\com\baidu\mapper\UsersMapper.java
     文件        7593  2016-12-04 14:19  ssm\src\com\baidu\mapper\UsersMapper.xml
............此处省略93个文件信息

评论

共有 条评论