- package cn.edu.hj.controller;
- import java.util.Map;
- import javax.servlet.http.HttpServletRequest;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
-
- @Controller
- public class HelloController {
-
- @RequestMapping(value = "/hello.htm")
- public String hello(int id){
- System.out.println("hello action:"+id);
- return "redirect:/index.jsp";
- }
-
-
- @RequestMapping(value = "/hello1.htm")
- public String hello(int id,Map<String,Object> map){
- System.out.println("hello1 action:"+id);
- map.put("name", "huangjie");
- return "hello";
- }
-
-
- @RequestMapping(value = "/hello2.htm")
- public String hello2(int id,Model model){
- System.out.println("hello2 action:"+id);
- model.addAttribute("name", "huangjie");
-
- model.addAttribute("ok");
- return "hello";
- }
-
-
- @RequestMapping(value = "/hello3.htm")
- public String hello3(HttpServletRequest request){
- String id = request.getParameter("id");
- System.out.println("hello3 action:"+id);
- return "hello";
- }
- }