資源簡介
基于注解的Spring_mvc增刪改DEMO源碼
代碼片段和文件信息
package?com.mvc.controller;
import?java.util.List;
import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpServletResponse;
import?org.apache.commons.logging.Log;
import?org.apache.commons.logging.LogFactory;
import?org.springframework.beans.factory.annotation.Autowired;
import?org.springframework.stereotype.Controller;
import?org.springframework.ui.ModelMap;
import?org.springframework.web.bind.annotation.RequestMapping;
import?org.springframework.web.bind.annotation.RequestMethod;
import?org.springframework.web.bind.annotation.RequestParam;
import?org.springframework.web.servlet.ModelAndView;
import?com.mvc.entity.Student;
import?com.mvc.service.StudentService;
@Controller
@RequestMapping(“/student.do“)
public?class?StudentController?{
protected?final?transient?Log?log?=?LogFactory
.getLog(StudentController.class);
@Autowired
private?StudentService?studentService;
public?StudentController(){
}
@RequestMapping
public?String?load(ModelMap?modelMap){
Listject>?list?=?studentService.getStudentList();
modelMap.put(“list“?list);
return?“student“;
}
@RequestMapping(params?=?“method=add“)
public?String?add(HttpServletRequest?request?ModelMap?modelMap)?throws?Exception{
return?“student_add“;
}
@RequestMapping(params?=?“method=save“)
public?String?save(HttpServletRequest?request?ModelMap?modelMap){
String?user?=?request.getParameter(“user“);
String?psw?=?request.getParameter(“psw“);
Student?st?=?new?Student();
st.setUser(user);
st.setPsw(psw);
try{
studentService.save(st);
modelMap.put(“addstate“?“添加成功“);
}
catch(Exception?e){
log.error(e.getMessage());
modelMap.put(“addstate“?“添加失敗“);
}
return?“student_add“;
}
@RequestMapping(params?=?“method=del“)
public?void?del(@RequestParam(“id“)?String?id?HttpServletResponse?response){
try{
Student?st?=?new?Student();
st.setId(Integer.valueOf(id));
studentService.delete(st);
response.getWriter().print(“{\“del\“:\“true\“}“);
}
catch(Exception?e){
log.error(e.getMessage());
e.printStackTrace();
}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????848??2010-11-26?23:32??s3h3\.classpath
?????文件???????1037??2010-11-26?23:32??s3h3\.project
?????文件????????454??2010-11-26?23:32??s3h3\.settings\.jsdtscope
?????文件????????330??2010-11-26?23:32??s3h3\.settings\org.eclipse.jdt.core.prefs
?????文件????????442??2010-11-26?23:32??s3h3\.settings\org.eclipse.wst.common.component
?????文件????????323??2010-11-26?23:32??s3h3\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件?????????49??2010-11-26?23:32??s3h3\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2010-11-26?23:32??s3h3\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????目錄??????????0??2010-11-26?23:32??s3h3\.settings
?????文件???????2579??2010-11-27?11:33??s3h3\build\classes\applicationContext.xm
?????文件???????3411??2010-11-27?12:23??s3h3\build\classes\com\mvc\controller\StudentController.class
?????目錄??????????0??2010-11-27?00:30??s3h3\build\classes\com\mvc\controller
?????文件????????365??2010-11-27?00:25??s3h3\build\classes\com\mvc\dao\EntityDao.class
?????文件???????1351??2010-11-27?00:25??s3h3\build\classes\com\mvc\dao\EntityDaoImpl$1.class
?????文件???????1107??2010-11-27?00:25??s3h3\build\classes\com\mvc\dao\EntityDaoImpl$2.class
?????文件???????1041??2010-11-27?00:25??s3h3\build\classes\com\mvc\dao\EntityDaoImpl$3.class
?????文件???????1041??2010-11-27?00:25??s3h3\build\classes\com\mvc\dao\EntityDaoImpl$4.class
?????文件???????1596??2010-11-27?00:25??s3h3\build\classes\com\mvc\dao\EntityDaoImpl.class
?????目錄??????????0??2010-11-27?00:25??s3h3\build\classes\com\mvc\dao
?????文件???????1452??2010-11-27?12:23??s3h3\build\classes\com\mvc\entity\Student.class
?????目錄??????????0??2010-11-27?00:25??s3h3\build\classes\com\mvc\entity
?????文件???????1644??2010-11-27?02:48??s3h3\build\classes\com\mvc\service\StudentService.class
?????目錄??????????0??2010-11-27?01:07??s3h3\build\classes\com\mvc\service
?????目錄??????????0??2010-11-27?00:25??s3h3\build\classes\com\mvc
?????目錄??????????0??2010-11-27?00:25??s3h3\build\classes\com
?????文件????????455??2010-11-26?01:02??s3h3\build\classes\hibernate.properties
?????文件????????259??2010-11-27?01:03??s3h3\build\classes\log4j.properties
?????目錄??????????0??2010-11-27?11:33??s3h3\build\classes
?????目錄??????????0??2010-11-26?23:32??s3h3\build
?????文件???????2579??2010-11-27?11:33??s3h3\src\applicationContext.xm
............此處省略71個文件信息
評論
共有 條評論