@Scope: 用于指定单例模式与多例模式,不写默认为单例模式,即 @Scope=“singleton”,如需使用多例可将参数更改为 prototype
@RequestParam: 接收前段传来的数据,并赋值给所注解参数
用法示例:
@Controller
@Scope("prototype")//更改模式为多例
public class LoginController {
@RequestMapping("/test1.htm")
public void test1(@RequestParam(name = "username") String name, @RequestParam(name = "password") String pw,
@RequestParam(name = "age") Integer iage) {
System.out.println(name);
System.out.println(pw);
System.out.println(iage);
}
}
注: @RequestParam注解中name的变量名必须与前端传来的变量名相同