|
@@ -0,0 +1,86 @@
|
|
|
+package com.lovecoding.springmvc;
|
|
|
+
|
|
|
+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.ResponseBody;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping("/student")
|
|
|
+public class StudentController {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增操作
|
|
|
+ * @param studentId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(
|
|
|
+ value ="/{studentId}",
|
|
|
+ method = RequestMethod.POST)
|
|
|
+ public String add(@PathVariable(
|
|
|
+ value = "studentId",
|
|
|
+ required = true) Long studentId, HttpSession httpSession){
|
|
|
+ System.out.println( "新增学员操作成功!!: " + studentId );
|
|
|
+ httpSession.setAttribute("action", "添加成功 ID:" + studentId);
|
|
|
+
|
|
|
+ return "/success.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除操作
|
|
|
+ * @param studentId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(
|
|
|
+ value ="/{studentId}",
|
|
|
+ method = RequestMethod.DELETE)
|
|
|
+ @ResponseBody
|
|
|
+ public String del(@PathVariable(
|
|
|
+ value = "studentId",
|
|
|
+ required = true) Long studentId, HttpSession httpSession){
|
|
|
+ System.out.println( "删除学员操作成功!!: " + studentId );
|
|
|
+ httpSession.setAttribute("action", "删除成功 ID:" + studentId);
|
|
|
+
|
|
|
+ return "Delete Student Success!!: " + studentId;
|
|
|
+ //return "/success.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改操作
|
|
|
+ * @param studentId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(
|
|
|
+ value ="/{studentId}",
|
|
|
+ method = RequestMethod.PUT)
|
|
|
+ @ResponseBody
|
|
|
+ public String update(@PathVariable(
|
|
|
+ value = "studentId",
|
|
|
+ required = true) Long studentId, HttpSession httpSession){
|
|
|
+ System.out.println( "修改学员操作成功!!: " + studentId );
|
|
|
+ httpSession.setAttribute("action", "修改成功 ID:" + studentId);
|
|
|
+ return "Update Student Success!!: " + studentId;
|
|
|
+ //return "/success.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询操作
|
|
|
+ * @param studentId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(
|
|
|
+ value ="/{studentId}",
|
|
|
+ method = RequestMethod.GET)
|
|
|
+ public String get(@PathVariable(
|
|
|
+ value = "studentId",
|
|
|
+ required = true) Long studentId, HttpSession httpSession){
|
|
|
+ System.out.println( "查询学员操作成功!!: " + studentId );
|
|
|
+ httpSession.setAttribute("action", "查询成功 ID:" + studentId);
|
|
|
+
|
|
|
+ return "/success.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+}
|