资源简介

spring+Mybatis+SpringMVC资源整合(增删改查+模糊查询)精心制作,适合新手学习。采用myeclipse,mysql数据库,内附sql文件。 首页路径:http://localhost:8080/springmvc4/user/search

资源截图

代码片段和文件信息

package com.aaa.controller;

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

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import com.aaa.service.IUserService;
import com.aaa.vo.User;

@Controller
@RequestMapping(“/user“)
public class UserController {
//成员:有一个业务层对象
@Resource
private IUserService userService;


@RequestMapping(“/toReg“)
public String toReg(){
return “user/reg“;
}
@RequestMapping(“/toLogin“)
public String toLogin(){
return “user/login“;
}
@RequestMapping(“/login“)
public ModelAndView login(@RequestParam(“username“) String username
@RequestParam(“password“) String passwordHttpSession sessionModelAndView mv){


return mv;
}





//ע�Ṧ��
@RequestMapping(“/reg“)
public String reg(User userHttpServletRequest request@RequestParam(“mf“)MultipartFile mf){
System.out.println(“++++++++“);
try {
File file=new File(mf.getOriginalFilename());
FileUtils.copyInputStreamToFile(mf.getInputStream()file);
System.out.println(file.getAbsolutePath().toString());
} catch (Exception e) {
e.printStackTrace();
}
return “user/login“;
}

@RequestMapping(“/toAdd“)
public String toAdd(){
return “user/add“;
}

@RequestMapping(“/add“)
public String add(User user){
userService.add(user);
return “redirect:search“;
}
//对user表查找;model:存放数据
@RequestMapping(“/search“)
public String searchAll(Model model){
ListuserList=userService.search();
model.addAttribute(“size“userList.size());
model.addAttribute(“userList“userList);
return “user/userList“; //viewName
}


//对user表查找;model:存放数据
/*@RequestMapping(“/select“)
public ModelAndView select(@RequestParam(“username“) String usernameMap map){
ModelAndView mv=new ModelAndView();

ListselectList=userService.select(map);
System.out.println(selectList.size());
mv.addobject(“selectList“ selectList);
mv.setViewName(“redirect:search“);//viewName
return mv;
}*/

@RequestMapping(“/seAll“)
public String select(User userModel model){
System.out.println(user.getUsername());
List userList = userService.seAll(user);
model.addAttribute(“userList“ userList);
return “user/userList“;
}

@RequestMapping(“/del/{username}“)
public  String del(@PathVariable(“username“)String username){
System.out.println(username);
int dell=userService.del(username);

retur

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

     文件       1076  2017-12-19 16:30  springmvc4\.classpath

     文件        303  2017-12-28 18:56  springmvc4\.mymetadata

     文件       1961  2017-12-19 16:32  springmvc4\.project

     文件        500  2017-12-19 16:29  springmvc4\.settings\.jsdtscope

     文件        145  2017-12-28 21:58  springmvc4\.settings\org.eclipse.core.resources.prefs

     文件        395  2017-12-19 16:29  springmvc4\.settings\org.eclipse.jdt.core.prefs

     文件        468  2017-12-19 16:29  springmvc4\.settings\org.eclipse.wst.common.component

     文件        252  2017-12-19 16:29  springmvc4\.settings\org.eclipse.wst.common.project.facet.core.xml

     文件         49  2017-12-19 16:29  springmvc4\.settings\org.eclipse.wst.jsdt.ui.superType.container

     文件          6  2017-12-19 16:29  springmvc4\.settings\org.eclipse.wst.jsdt.ui.superType.name

     文件        415  2017-12-19 16:30  springmvc4\.springBeans

     文件       1054  2017-12-30 13:22  springmvc4\sql\test.sql

     文件       3500  2017-12-30 13:14  springmvc4\src\com\aaa\controller\UserController.java

     文件        391  2017-12-29 17:07  springmvc4\src\com\aaa\dao\UserDao.java

     文件       1047  2017-12-29 17:06  springmvc4\src\com\aaa\mapper\UserDaoMapper.xml

     文件       1161  2017-12-30 13:06  springmvc4\src\com\aaa\service\impl\UserService.java

     文件        386  2017-12-29 17:08  springmvc4\src\com\aaa\service\IUserService.java

     文件       1288  2017-12-29 17:01  springmvc4\src\com\aaa\vo\User.java

     文件        296  2017-05-06 00:00  springmvc4\src\com\util\DateConverter.java

     文件        338  2017-12-28 16:31  springmvc4\src\com\util\HrmConstants.java

     文件       4439  2017-05-05 00:00  springmvc4\src\com\util\objectTools.java

     文件        559  2017-05-03 00:00  springmvc4\src\com\util\PageData.java

     文件       3131  2017-05-04 00:00  springmvc4\src\com\util\PageUtil.java

     文件       1796  2017-12-19 15:33  springmvc4\src\com\util\UserInterceptor.java

     文件        838  2017-12-19 16:36  springmvc4\WebRoot\index.jsp

     文件         36  2017-12-19 16:29  springmvc4\WebRoot\meta-INF\MANIFEST.MF

     文件       4829  2017-12-30 13:14  springmvc4\WebRoot\WEB-INF\classes\com\aaa\controller\UserController.class

     文件        508  2017-12-30 13:04  springmvc4\WebRoot\WEB-INF\classes\com\aaa\dao\UserDao.class

     文件       1047  2017-12-29 17:06  springmvc4\WebRoot\WEB-INF\classes\com\aaa\mapper\UserDaoMapper.xml

     文件       1497  2017-12-30 13:06  springmvc4\WebRoot\WEB-INF\classes\com\aaa\service\impl\UserService.class

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

评论

共有 条评论