注解分析
1.1@RequestMapping
- RequestMapping(“hello”);--开发常用比较灵活
- RequestMapping(“/hello.do”);--带有扩展名
- RequestMapping(value =“/hello.do”);
- RequestMapping(value =“/hello.do”, method=RequestMethod.GET);--指定请求方法
- RequestMapping(value =“/hello.do”, method={RequestMethod.GET,RequestMethod.GET});--同时允许get和post请求方法
- 2自定义Controller 类
- @Controller--<bean class="com.zit.controller.UserController">
package com.zit.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class UserController {
@RequestMapping(value="/login.do",method={RequestMethod.POST,RequestMethod.GET})
public String sayHello(){
return "hello";
}
}