package com.test.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.test.model.Student;
import com.test.service.StudentManager;
/**
* @author FengJianBo
**/
@Controller
@RequestMapping("/student")
public class StudentController {
@Autowired
private StudentManager studentManager;
/**
* 按照id删除
* @author FengJianBo
* @param student
* @param request
* @param response
* @return
* 2014年3月25日 下午1:37:16
*/
@RequestMapping(value="/deleteById.do")
public String deleteById(HttpServletRequest request, HttpServletResponse response){
try{
String id = request.getParameter("id");
if(StringUtils.isNotEmpty(id)){
studentManager.deleteById(id);
}
} catch(Exception e){
}
return "redirect:../../"+request.getContextPath();
}
/**
* 表单提交
* @author FengJianBo
* @param student
* @param request
* @param response
* @return
* 2014年3月25日 下午1:37:16
*/
@RequestMapping(value="/submit.do")
public String submit(Student student,HttpServletRequest request, HttpServletResponse response){
try{
if(student != null){
if(StringUtils.isNotEmpty(student.getId())){
this.studentManager.update(student);
} else {
this.studentManager.add(student);
}
}
} catch(Exception e){
}
return "redirect:../../"+request.getContextPath()+"/student/showAll.do";
}
/**
* 显示详细信息
* @author FengJianBo
* @param student
* @param request
* @param response
* @return
* 2014年3月25日 下午1:37:16
*/
@RequestMapping(value="/showInfo.do")
public String showInfo(HttpServletRequest request, HttpServletResponse response){
Student student = null;
try{
String id = request.getParameter("id");
if(StringUtils.isNotEmpty(id)){
student = studentManager.findById(id);
}
if(student == null){
student = new Student();
}
} catch(Exception e){
}
request.setAttribute("student", student);
return "student/add";
}
/**
* 表单提交
* @author FengJianBo
* @param student
* @param request
* @param response
* @return
* 2014年3月25日 下午1:37:16
*/
@RequestMapping(value="/showAll.do")
public String showAll(HttpServletRequest request, HttpServletResponse response){
try {
request.setAttribute("students", studentManager.findAll());
} catch (Exception e) {
e.printStackTrace();
}
return "student/showAll";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
springMVC4+Hibernate4整合例子
共44个文件
java:10个
class:10个
xml:6个
5星 · 超过95%的资源 需积分: 9 805 下载量 61 浏览量
2014-05-14
18:29:45
上传
评论 7
收藏 32KB ZIP 举报
温馨提示
springMVC4整合hibernate4的例子,用的是maven所以项目里面没有jar包. 工具用的是eclipse 表结构在doc文件夹下面.
资源推荐
资源详情
资源评论
收起资源包目录
student.zip (44个子文件)
student
.project 1KB
src
test
java
main
webapp
WEB-INF
pages
student
showAll.jsp 792B
add.jsp 582B
springmvc-servlet.xml 3KB
web.xml 2KB
index.jsp 167B
resources
applicationContext.xml 5KB
jdbc.properties 134B
log4j.properties 600B
common.properties 41B
java
com
test
service
StudentManager.java 166B
impl
BaseManagerImpl.java 836B
StudentManagerImpl.java 320B
BaseManager.java 776B
model
Student.java 1006B
controller
StudentController.java 3KB
dao
StudentDao.java 175B
impl
StudentDaoImpl.java 327B
BaseDaoImpl.java 3KB
BaseDao.java 784B
target
classes
applicationContext.xml 5KB
com
test
service
impl
StudentManagerImpl.class 617B
BaseManagerImpl.class 2KB
StudentManager.class 259B
BaseManager.class 575B
model
Student.class 1KB
controller
StudentController.class 3KB
dao
impl
BaseDaoImpl.class 4KB
StudentDaoImpl.class 564B
BaseDao.class 563B
StudentDao.class 231B
jdbc.properties 134B
log4j.properties 600B
common.properties 41B
test-classes
doc
student.sql 167B
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 252B
org.eclipse.m2e.core.prefs 90B
org.eclipse.jdt.core.prefs 664B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.component 640B
.jsdtscope 494B
pom.xml 5KB
.classpath 1KB
共 44 条
- 1
灰祥的奇迹
- 粉丝: 0
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页