springwebMVC学习笔记

来源:互联网 发布:官路淘宝 小说 编辑:程序博客网 时间:2024/05/21 14:05

note:

postHandle is less useful with @ResponseBody and ResponseEntity methods for which a the response is written and commited within the HandleAdapter and before postHandle.

That means its too late to make any changes to the response such as adding an extra header.

For such scenarios you can implement ResponseBodyAdvice and either declare it as an Controller Advice bean or configure it directly on RequestMappingHandlerAdapter.


In order to use Excel views,you need to add the Apache POI library to your classpath,and for PDF library to your classpath, and for PDF generation, the common iText 2.1.7 or 

its fork OpenPDF (e.g. OpenPDF 1.0.4)


RestTemple has a synchronous API and relies on blocking I/O . 

this is okay for client scenarios with low concurrency. 

In a server environment or when orchestrating a sequence of remote calls, prefer using theWebClient which provides a more efficient execution model including seamless support for streaming.


Note that if a WebSocket server is running behind a web server (e.g. nginx) you will likely need to configure it to pass WebSocket upgrade it to pass WebSocket server.

Likewise if the application runs in a cloud environmnet , check the instructions of the cloud provider related to WebSocket support.


@PostMapping(path = "/pets", consumes ="application/json")
public vod addPet(@RequestBody Pet pet){}
//consumes:The Content-Type of the request;
//produces:The Accept of the request; 

原创粉丝点击