1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| package com.runsstudio.springmvc.servlet;
import org.springframework.stereotype.Controller; import org.springframework.ui.Model; 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.servlet.View;
@Controller
public class RequestMappingControllerTester {
@RequestMapping(value = "/handle01" ,params = {"!username"},method = RequestMethod.GET) public String handle01(){ System.out.println("RequestMappingControllerTester..handle01"); return "success"; }
@RequestMapping(value = "/onlyFirefox" ,headers = {"User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0"}) public String onlyFirefox(Model model){ System.out.println("firefox..."); model.addAttribute("name","firefox"); model.addAttribute("time",System.currentTimeMillis()); return "success"; }
@RequestMapping(value = "/AntStyleURL?") public String AntStyleUrl01(Model model){ System.out.println("AntStyleUrl"); model.addAttribute("name","AntStyleURL"); return "success"; } @RequestMapping(value = "/AntStyleURL*") public String AntStyleUrl02(Model model){ System.out.println("AntStyleUrl2"); model.addAttribute("name","AntStyleURL2"); return "success"; }
@RequestMapping("/user/{id}") public String pathVariableTest(@PathVariable("id")String id,Model model){ System.out.println("占位符的值:"+id); model.addAttribute("name",id); return "success"; }
}
|