资源简介

使用springMVC+mybatis框架,使用spring自动装配技术实现增删改查功能,适合初学者。

资源截图

代码片段和文件信息

package com.aryasec.test.Controller;


import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.aryasec.test.Model.User;
import com.aryasec.test.Model.dao.UserMapper;
import com.aryasec.test.Service.UserService;

@Controller
@RequestMapping(“/UserController“)
public class UserController {
@Resource
    private UserService userService;
/*
 * 新增用户信息
 */
@RequestMapping(“/insert“)
public ModelAndView insert(String usernameString password)
{
ModelAndView mav = new ModelAndView();
User user = new User();

user.setId(59);
user.setName(username);
user.setBirthday(password);
user.setSalary(1000);
userService.save(user);

System.out.println(username);
System.out.println(password);

mav.addobject(“msg““跳转成功“);
mav.addobject(“password“password);
mav.setViewName(“insert“);
return mav;
}
/*
 * 修改用户信息
 */
@RequestMapping(“/update“)
public ModelAndView update(String usernameString password)
{
ModelAndView mav = new ModelAndView();
User user =new User();
int id = 3;
user    = userService.findById(id);
System.out.println(user.getName());
user.setName(username);
user.setBirthday(password);
userService.update(user);

mav.addobject(“msg““修改成功“);
mav.setViewName(“update“);
return mav;
}

/*
 * 查看用户信息
 */
@RequestMapping(“/findall“)
public ModelAndView findAll()
{
ModelAndView mav = new ModelAndView();
List list=userService.findAll();
System.out.println(“查看用户信息“);
for(int i=0; i User obj = list.get(i);
System.out.println(obj.toString());
}
mav.addobject(“list“list);
mav.addobject(“msg““查看信息“);
mav.setViewName(“findall“);
return mav;
}

/*
 * 删除用户信息
 */
@RequestMapping(“/delete“)
public ModelAndView delete()
{
ModelAndView mav = new ModelAndView();

System.out.println(“查看用户信息“);
int id =4;
userService.delete(id);

mav.addobject(“msg““删除成功“);
mav.setViewName(“delete“);
return mav;
}





/*@Test
public void testAdd(){
User user = new User(3“tom““20120101“1200);
userMapper.save(user);
}*/
/*@RequestMapping(“/update“)
public void testUpdate(){
User user = userMapper.findById(2);
user.setSalary(1901);
userMapper.update(user);
}  */
/*@Test
public void testFindAll(){

System.out.println(userMapper.findAll()) ;
}
*/
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-12-08 16:35  smproject\
     文件        3244  2016-12-09 11:30  smproject\.classpath
     文件         909  2016-12-08 16:35  smproject\.project
     目录           0  2016-12-09 12:33  smproject\.settings\
     文件         567  2016-12-08 16:35  smproject\.settings\.jsdtscope
     文件         185  2016-12-13 14:18  smproject\.settings\org.eclipse.core.resources.prefs
     文件         364  2016-12-08 16:35  smproject\.settings\org.eclipse.jdt.core.prefs
     文件         479  2016-12-08 16:35  smproject\.settings\org.eclipse.wst.common.component
     文件         345  2016-12-08 16:35  smproject\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2016-12-08 16:35  smproject\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2016-12-08 16:35  smproject\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2016-12-08 16:35  smproject\build\
     目录           0  2016-12-13 17:26  smproject\build\classes\
     目录           0  2016-12-13 12:35  smproject\build\classes\com\
     目录           0  2016-12-13 12:35  smproject\build\classes\com\aryasec\
     目录           0  2016-12-13 12:35  smproject\build\classes\com\aryasec\test\
     目录           0  2016-12-13 12:35  smproject\build\classes\com\aryasec\test\Controller\
     文件        2997  2016-12-13 14:19  smproject\build\classes\com\aryasec\test\Controller\UserController.class
     目录           0  2016-12-13 12:35  smproject\build\classes\com\aryasec\test\Model\
     目录           0  2016-12-13 12:35  smproject\build\classes\com\aryasec\test\Model\dao\
     文件         384  2016-12-13 12:35  smproject\build\classes\com\aryasec\test\Model\dao\UserMapper.class
     文件        1678  2016-12-13 12:35  smproject\build\classes\com\aryasec\test\Model\User.class
     目录           0  2016-12-13 12:35  smproject\build\classes\com\aryasec\test\Service\
     文件         384  2016-12-13 12:35  smproject\build\classes\com\aryasec\test\Service\UserService.class
     文件        1332  2016-12-13 12:35  smproject\build\classes\com\aryasec\test\Service\UserServiceImpl.class
     文件         391  2016-12-08 12:31  smproject\build\classes\mybatis-config.xml
     文件        4171  2016-12-13 17:26  smproject\build\classes\springmvc.xml
     目录           0  2016-12-13 14:02  smproject\build\classes\sqlmapper\
     文件        1077  2016-12-13 14:02  smproject\build\classes\sqlmapper\userMapper.xml
     目录           0  2016-12-09 10:13  smproject\src\
     目录           0  2016-12-08 16:37  smproject\src\com\
............此处省略59个文件信息

评论

共有 条评论