Spring Data MongoDB - Spring Web Services - Parent - SpringSource
Spring Data MongoDB - Spring Web Services - Parent - SpringSource Spring Data MongoDB - Spring Web Services - Parent - SpringSource
please define productname in your docbook file!@Controller@RequestMapping("/users")public class UserController {@RequestMapping("/{id}")public String showUserForm(@PathVariable("id") User user, Model model) {}}model.addAttribute("user", user);return "userForm";ConversionServiceIn Spring 3.0 and later the PropertyEditor support is superseded by a new conversion infrastructurethat eliminates the drawbacks of PropertyEditors and uses a stateless X to Y conversionapproach. Spring Data now ships with a DomainClassConverter that mimics the behavior ofDomainClassPropertyEditorRegistrar. To configure, simply declare a bean instance and pipethe ConversionService being used into its constructor:If you are using JavaConfig, you can simply extend Spring MVC's WebMvcConfigurationSupportand hand the FormatingConversionService that the configuration superclass provides into theDomainClassConverter instance you create.class WebConfiguration extends WebMvcConfigurationSupport {// Other configuration omitted}@Beanpublic DomainClassConverter domainClassConverter() {return new DomainClassConverter(mvcConversionService());}Web paginationWhen working with pagination in the web layer you usually have to write a lot of boilerplate code yourselfto extract the necessary metadata from the request. The less desirable approach shown in the examplebelow requires the method to contain an HttpServletRequest parameter that has to be parsedmanually. This example also omits appropriate failure handling, which would make the code even moreverbose.1.4.0.BUILD-SNAPSHOTSpring Data MongoDB -Reference Documentation 21
please define productname in your docbook file!@Controller@RequestMapping("/users")public class UserController {// DI code omitted@RequestMappingpublic String showUsers(Model model, HttpServletRequest request) {int page = Integer.parseInt(request.getParameter("page"));int pageSize = Integer.parseInt(request.getParameter("pageSize"));Pageable pageable = new PageRequest(page, pageSize);}}model.addAttribute("users", userService.getUsers(pageable));return "users";The bottom line is that the controller should not have to handle the functionality of extracting paginationinformation from the request. So Spring Data ships with a PageableHandlerArgumentResolverthat will do the work for you. The Spring MVC JavaConfig support exposes aWebMvcConfigurationSupport helper class to customize the configuration as follows:@Configurationpublic class WebConfig extends WebMvcConfigurationSupport {}@Overridepublic void configureMessageConverters(List
- Page 1 and 2: Spring Data MongoDB - Reference Doc
- Page 3 and 4: please define productname in your d
- Page 5 and 6: please define productname in your d
- Page 7 and 8: please define productname in your d
- Page 9 and 10: please define productname in your d
- Page 11: please define productname in your d
- Page 14 and 15: please define productname in your d
- Page 16 and 17: please define productname in your d
- Page 18 and 19: please define productname in your d
- Page 20 and 21: please define productname in your d
- Page 22 and 23: please define productname in your d
- Page 24 and 25: please define productname in your d
- Page 28 and 29: please define productname in your d
- Page 30 and 31: please define productname in your d
- Page 32 and 33: please define productname in your d
- Page 34 and 35: please define productname in your d
- Page 36 and 37: please define productname in your d
- Page 38 and 39: please define productname in your d
- Page 40 and 41: please define productname in your d
- Page 42 and 43: please define productname in your d
- Page 44 and 45: please define productname in your d
- Page 46 and 47: please define productname in your d
- Page 48 and 49: please define productname in your d
- Page 50 and 51: please define productname in your d
- Page 52 and 53: please define productname in your d
- Page 54 and 55: please define productname in your d
- Page 56 and 57: please define productname in your d
- Page 58 and 59: please define productname in your d
- Page 60 and 61: please define productname in your d
- Page 62 and 63: please define productname in your d
- Page 64 and 65: please define productname in your d
- Page 66 and 67: please define productname in your d
- Page 68 and 69: please define productname in your d
- Page 70 and 71: please define productname in your d
- Page 72 and 73: please define productname in your d
- Page 74 and 75: please define productname in your d
please define productname in your docbook file!@Controller@RequestMapping("/users")public class UserController {// DI code omitted@RequestMappingpublic String showUsers(Model model, HttpServletRequest request) {int page = Integer.parseInt(request.getParameter("page"));int pageSize = Integer.parseInt(request.getParameter("pageSize"));Pageable pageable = new PageRequest(page, pageSize);}}model.addAttribute("users", userService.getUsers(pageable));return "users";The bottom line is that the controller should not have to handle the functionality of extracting paginationinformation from the request. So <strong>Spring</strong> <strong>Data</strong> ships with a PageableHandlerArgumentResolverthat will do the work for you. The <strong>Spring</strong> MVC JavaConfig support exposes a<strong>Web</strong>MvcConfigurationSupport helper class to customize the configuration as follows:@Configurationpublic class <strong>Web</strong>Config extends <strong>Web</strong>MvcConfigurationSupport {}@Overridepublic void configureMessageConverters(List