@RequestMapping("/pageList") @ResponseBody public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int start, @RequestParam(required = false, defaultValue = "10") int length, int jobGroup, String jobDesc, String executorHandler, String filterTime) { return xxlJobService.pageList(start, length, jobGroup, jobDesc, executorHandler, filterTime); }
@Controller @RequestMapping("/hotels/{hotel}") public static class RelativePathUriTemplateController { @RequestMapping("bookings/{booking}") public void handle(@PathVariable("hotel") String hotel, @PathVariable int booking, Writer writer) throws IOException { assertEquals("Invalid path variable value", "42", hotel); assertEquals("Invalid path variable value", 21, booking); writer.write("test-" + hotel + "-" + booking); } }
@RequestMapping(value="/blog.atom", method = { GET, HEAD }) @ResponseBody public String listPublishedPosts() { return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + "<feed xmlns=\"http://www.w3.org/2005/Atom\">\r\n" + " <title>Test Feed</title>\r\n" + " <icon>http://www.example.com/favicon.ico</icon>\r\n" + "</feed>\r\n\r\n"; } }
@ApiOperation("分页查询商品分类") @RequestMapping(value = "/list/{parentId}", method = RequestMethod.GET) @ResponseBody @PreAuthorize("hasAuthority('pms:productCategory:read')") public Object getList(@PathVariable Long parentId, @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) { List<PmsProductCategory> productCategoryList = productCategoryService.getList(parentId, pageSize, pageNum); return new CommonResult().pageSuccess(productCategoryList); }
@ApiOperation("更新商品") @RequestMapping(value = "/update/{id}", method = RequestMethod.POST) @ResponseBody @PreAuthorize("hasAuthority('pms:product:update')") public Object update(@PathVariable Long id, @RequestBody PmsProductParam productParam, BindingResult bindingResult) { int count = productService.update(id, productParam); if (count > 0) { return new CommonResult().success(count); } else { return new CommonResult().failed(); } }
@RequestMapping("/{country}") HttpEntity<Void> getAddressesForCountry(@PathVariable String country) { return null; } }
@RequestMapping("/optional-param") HttpEntity<Void> methodWithOptionalParam(@RequestParam(defaultValue = "") String q) { return null; } }
@Controller @RequestMapping("/myPath.do") static class MyParameterDispatchingController implements Serializable { @Autowired private transient ServletContext servletContext; @Autowired private transient ServletConfig servletConfig; @Autowired private HttpSession session;
@RequestMapping(value = "/something", method = RequestMethod.PUT) @ResponseBody public String handle(@RequestBody String body) throws IOException { return body; }
@RequestMapping(path = "/a4.css", method = RequestMethod.GET) public String a4(@RequestBody String body) { return body; } }
@RequestMapping(value = "/{id}/foo") HttpEntity<Void> methodWithMultiValueRequestParams(@PathVariable String id, @RequestParam List<Integer> items, @RequestParam Integer limit) { return null; }
@RequestMapping(value="/person/{name}") @ResponseBody public Person get(@PathVariable String name) { return new Person(name); } }
@ApiOperation(value = "根据商品id推荐商品") @RequestMapping(value = "/recommend/{id}",method = RequestMethod.GET) @ResponseBody public Object recommend(@PathVariable Long id, @RequestParam(required = false, defaultValue = "0") Integer pageNum, @RequestParam(required = false, defaultValue = "5") Integer pageSize){ Page<EsProduct> esProductPage = esProductService.recommend(id, pageNum, pageSize); return new CommonResult().pageSuccess(esProductPage); }
@ApiOperation("修改关联相关信息") @RequestMapping(value = "/update/{id}", method = RequestMethod.POST) @ResponseBody public Object update(@PathVariable Long id, @RequestBody SmsFlashPromotionProductRelation relation) { int count = relationService.update(id,relation); if(count>0){ return new CommonResult().success(count); } return new CommonResult().failed(); }
@Controller @RequestMapping("/test") public static class VariableNamesController { @RequestMapping(value = "/{foo}", method=RequestMethod.GET) public void foo(@PathVariable String foo, Writer writer) throws IOException { writer.write("foo-" + foo); } @RequestMapping(value = "/{bar}", method=RequestMethod.DELETE) public void bar(@PathVariable String bar, Writer writer) throws IOException { writer.write("bar-" + bar); } }
@RequestMapping("/create") public String showCreate(@PathVariable Integer userId) { return null; } }
@RequestMapping("/singleString") public void processMultipart(@RequestParam("content") String content, HttpServletResponse response) throws IOException { response.getWriter().write(content); }
@RequestMapping(value="/handleUtf8", produces="text/plain;charset=UTF-8") @ResponseBody public String handleWithCharset() { return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01"; // "Hello world! (Japanese) } }
@RequestMapping(value = "/something", method = RequestMethod.PATCH) @ResponseBody public String handlePartialUpdate(@RequestBody String content) throws IOException { return content; } }
@RequestMapping(path = "/a1", method = RequestMethod.GET) public String a1(@RequestBody String body) { return body; }