package com.zj.controller;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.taglibs.standard.tag.el.sql.UpdateTag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.sun.corba.se.spi.orbutil.fsm.Input;
import com.sun.org.apache.bcel.internal.generic.NEW;
import com.zj.dao.StudentDao;
import com.zj.model.Student;
/**
* 学生控制器类
* @author zhoujun
*
*/
@Controller
public class StudentCtrl {
@Autowired
private StudentDao studentDao;
/**
* 显示学生列表
* @param map
* @return
*/
@RequestMapping("/student")
public String list(Map<String, Object> map){
map.put("students", studentDao.getAll());
return "list";
}
/**
* 增加学生
* @param student
* @return
* @throws UnsupportedEncodingException
*/
@RequestMapping(value="student",method=RequestMethod.POST)
public String add(Student student){
studentDao.add(student);
return "redirect:/student";//重定向到 显示学生列表界面
}
/**
* 增加学生 页面
* @param map
* @return
*/
@RequestMapping("/input")
public String input(Map<String, Object> map){
//将性别的选项放入map中,springmvc的form:radiobuttons标签将自行解析
Map<String, String> sexMap = new HashMap<String, String>();
sexMap.put("男", "男");
sexMap.put("女", "女");
map.put("sex", sexMap);
//放入一个默认的空的信息
map.put("student", new Student());
return "input";
}
/**
* 修改学生 界面
* @param studentId
* @param map
* @return
*/
@RequestMapping("/student/{studentId}")
public String Input(@PathVariable("studentId")Integer studentId,
Map<String, Object> map){
//将性别的选项放入map中,springmvc的form:radiobuttons标签将自行解析
Map<String, String> sexMap = new HashMap<String, String>();
sexMap.put("男", "男");
sexMap.put("女", "女");
map.put("sex", sexMap);
map.put("student", studentDao.getById(studentId));
return "input";
}
/**
* 修改学生信息
* @param student
* @return
*/
@RequestMapping(value="student",method=RequestMethod.PUT)
public String Update(Student student){
studentDao.update(student);
return "redirect:/student";
}
/**
* 删除一个学生
* @param studentId---学生ID
* @return
*/
@RequestMapping(value = "student/{studentId}",method=RequestMethod.DELETE)
public String delete(@PathVariable("studentId")Integer studentId){
studentDao.delete(studentId);
return "redirect:/student";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
springmvc01.zip (40个子文件)
springmvc01
.project 1008B
WebContent
WEB-INF
views
hello.jsp 361B
index.jsp 540B
input.jsp 1KB
list.jsp 1KB
lib
spring-context-4.0.0.RELEASE.jar 928KB
spring-expression-4.0.0.RELEASE.jar 202KB
spring-webmvc-4.0.0.RELEASE.jar 645KB
jstl.jar 20KB
spring-web-4.0.0.RELEASE.jar 646KB
spring-aop-4.0.0.RELEASE.jar 343KB
spring-beans-4.0.0.RELEASE.jar 654KB
commons-logging-1.1.1.jar 59KB
spring-core-4.0.0.RELEASE.jar 933KB
commons-io-2.0.jar 156KB
commons-fileupload-1.2.1.jar 56KB
standard.jar 384KB
web.xml 2KB
js
jquery-1.8.2.min.js 91KB
META-INF
MANIFEST.MF 39B
src
com
zj
model
Student.java 921B
Address.java 534B
controller
TestCtrl.java 2KB
StudentCtrl.java 3KB
dao
StudentDao.java 2KB
springmvc.xml 2KB
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 335B
org.eclipse.jdt.core.prefs 357B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.core.resources.prefs 55B
org.eclipse.wst.common.component 477B
.jsdtscope 491B
build
classes
com
zj
model
Address.class 865B
Student.class 1KB
controller
StudentCtrl.class 3KB
TestCtrl.class 3KB
dao
StudentDao.class 2KB
springmvc.xml 2KB
.classpath 824B
共 40 条
- 1
资源评论
- alphazzz2017-10-02压缩包坏了
- R_2016-11-04很简单的一个demo 适合新人
- 微程序员2017-10-24我下载了,可是不能用啊
- kpppkk2015-07-19这个资源不错,很好用
君君要上天
- 粉丝: 530
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功