RestFul style
concept
Restful style is a resource location and resource operations. Not standard protocol is not just a style. Based on this style of design software more concise, more structured and easier to implement caching mechanisms.
Features
- Resources: Internet everything can be abstracted as resources
- Resource operation: Use a different POST, DELETE, PUT, GET, use of resources operation
- Respectively add, delete, modify, query.
The traditional way of operating resources : to achieve different effects by different parameters! A single method, post and get
- http://127.0.0.1/item/queryltem.action?id=1 query, GET
- http://127.0.0.1/item/saveltem.action new, POST
- http://127.0.0.1/item/updateItem.action update, POST
- http://127.0.0.1/item/deleteItem.action?id=1 delete, GET or POST
Operation using RESTful resources : different effects may be achieved by different request! As follows: as request address, but the function may be different
- http://127.0.0.1/item/1 query, GET
- http://127.0.0.1/item/1 new, POST
- http://127.0.0.1/item/1 update, PUT
- http://127.0.0.1/item/1 delete, DELETE
Forwards the request forward
@Controller
public class ModelTest {
@RequestMapping(path = "/m1/t1")
public String test(Model model) {
model.addAttribute("msg","ModelTest");
return "forward:/WEB-INF/jsp/test.jsp";
}
}
Redirect redirect
@Controller
public class ModelTest {
@RequestMapping(path = "/m1/t1")
public String test(Model model) {
model.addAttribute("msg","ModelTest");
return "redirect:/index.jsp";
}
}