springmvc 2 essays, annotations requestmapping

1. RequestMapping, in addition to modification methods, the class may be modified. In general, the content @RequestMapping java code annotated with slashes are used in. But in the jsp page, hyperlinks head start, not with a slash, otherwise reported 404 errors

2. RequestMapping, which has four parameters, namely, value, method, params, heads, a default value, i.e. above example. method have the values ​​@RequestMapping (value = "/ testhref", method = RequestMethod.POST). params and heads, these two are not commonly used.

3. RequestMapping support ant-style wildcards. ? Matches one character, * matches any character * match multi-layered path. This is generally done to understand, not commonly used.

4. @ PathVariable URL mapping placeholder binding, more critical points of this technique, the URL can speak by @PathVariable parameter placeholder bound to the parameters of the controller processing method, as

@RequestMapping ( "/ Delete / {ID}" ) // ID here, there is no double quotes, only one brace
 public String Delete (@PathVariable ( "ID") int ID) { 
      UserDao.delete (ID); 
      return "Success" ;   
}

The URL {xxx} placeholder can be bound to the operation by the method @PathVariable ( "xxx") into the ginseng. Master key

Guess you like

Origin www.cnblogs.com/sdgtxuyong/p/11613328.html