Category : spring-mvc

1. Preface I believe that every one of us encountered such problems in Spring MVC development: when our code runs normally, the returned data is in our expected format, such as json or xml, but once there is an exception (such as NPE or array cross-border, etc.), the returned content does contain the exception stack ..

Read more

Order Traditional spring is generally configured based on xml, but many comments of JavaConfig were added later. Springboot, in particular, is basically all java config. if you don’t understand it, you really don’t adapt. Note here. @RestController Spring4 has added RestController’s comments in order to more conveniently support the development of restfull applications. More functions ..

Read more

explain You can set them one by one using comments, and you can configure global settings using. CrossOrigin annotation @CrossOrigin(origins = “http://localhost:3000″) @RequestMapping(value=”/search”,method = RequestMethod.GET) @ResponseBody @ApiOperation(value = “查询”) public void search( @ApiParam(value = “分页,从0开始”) @RequestParam(required = false,defaultValue = “0”) int page, @ApiParam(value = “分页大小,默认10”) @RequestParam(required = false,defaultValue = “10”) int size) { … } ..

Read more

Receive bean @RequestMapping(value = “/test/query”,method = RequestMethod.GET) @ResponseBody public QueryParam getQueryByBean(QueryParam param, Order order) throws JsonProcessingException { System.out.println(objectMapper.writeValueAsString(order)); return param; } Without additional comments, bean properties can be automatically populated, where beans support nested objects, nested list objects, nested list simple types, nested array simple types Automatically populate simple attributes http://localhost:8080/test/query?id=1&count=3&name=111 Automatically populate multiple bean ..

Read more

Background There are some batch processing things, the background execution may time out, if you wait until you finally encounter an error or have any results, you will often time out, and the details of the entire execution process can’t be seen, it is a black box, not much debugging. Let’s talk about the effect ..

Read more

Order Previously, I wrote an article: springmvc continuously outputs text to web pages, using the implementation of write and flush on response. In Spring version 4.2, a SseEmitter was provided, which can be directly used to implement this function. Example @Controller @RequestMapping(“/sse”) public class SseEmitterController { private static final Logger LOGGER = LoggerFactory.getLogger(SseEmitterController.class); @Autowired @Qualifier(“mvcTaskExecutor”) ..

Read more