SpringMvc当中的请求参数注入获取方式是什么?
很好奇Spring是怎么去获取请求的参数的。
@RequestMapping("/req")
public void req(HttpServletRequest request,HttpServletResponse response,String id){
System.out.println(id);
}
public String getParameter(String name) {
String value = super.getParameter(name);
if(map!=null&&map.get(name)!=null){
value = (String)map.get(name);
}
return value;
}
/**
* ParameterMap
*/
public Map<String, String[]> getParameterMap() {
Map<String, String[]> map = new HashMap<String, String[]>();
map.putAll(super.getParameterMap());
try {
List<String> ls = new ArrayList<String>();
for (String str : map.keySet()) {
String[] s = map.get(str);
for (String v : s) {
ls.add(new XssFilter().filter(v));
}
map.put(str, ls.toArray(new String[ls.size()]));
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}