How to post response from worker thread to client via Spring MVC?

I am using spring tool suite 3.3.0. I have a request mapping in that I receive from client and start processing and call a different thread for my purpose. Is it possible to send response from worker thread? Code: @RequestMapping(value = "/rcv", method = RequestMethod.POST) public @ResponseBody String home() { //receving from client Thread th = new Thread(); // my thread proc

如何通过Spring MVC发布工作线程对客户端的响应?

我正在使用spring工具套件3.3.0。 我有一个请求映射,我从客户端收到并开始处理并为我的目的调用不同的线程。 是否有可能从工作线程发送响应? 代码:@RequestMapping(value =“/ rcv”,method = RequestMethod.POST) public @ResponseBody String home(){//从客户端接收 Thread th = new Thread(); // my thread process } 不,它应该以另一种方式工作。 首先你可以启动线程并将它存储在某个地方,例如在会

Spring MVC method handling json and form params

I want the handle the content types application/x-www-form-urlencoded and application/json in single spring mvc method. I've a requirement in rest service to accept input as form parameters or json. I can achieve this by writing two methods. Either form params or json, the response will be always json. @RequestMapping (method = RequestMethod.POST, produces = {"application/json"},

Spring MVC方法处理json和form params

我想在单弹簧mvc方法中处理内容类型application / x-www-form-urlencoded和application / json。 我有一个休息服务的要求,接受输入作为形式参数或JSON。 我可以通过写两种方法来实现这一点。 无论是形式参数还是json,响应总是json。 @RequestMapping (method = RequestMethod.POST, produces = {"application/json"}, consumes = {"application/x-www-form-urlencoded"}) public @ResponseBody Book createBook(Bo

Spring configure @ResponseBody JSON format

Imagine I have this annotated method in a Spring 3 @Controller @RequestMapping("") public @ResponseBody MyObject index(@RequestBody OtherObject obj) { MyObject result = ...; return result; } But I need to configure the output json format, just as if I were doing: ObjectMapper om = new ObjectMapper(); om.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true); om.getSerializationConfig

Spring配置@ResponseBody JSON格式

想象一下,我在Spring 3 @Controller中拥有这个注解的方法 @RequestMapping("") public @ResponseBody MyObject index(@RequestBody OtherObject obj) { MyObject result = ...; return result; } 但我需要配置输出json格式,就像我在做: ObjectMapper om = new ObjectMapper(); om.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true); om.getSerializationConfig() .setSerializationInclusion(Json

Spring 3 JSON with MVC

Is there a way to build Spring Web calls that consume and produce application/json formatted requests and responses respectively? Maybe this isn't Spring MVC, I'm not sure. I'm looking for Spring libraries that behave in a similar fashion to Jersey/JSON. The best case would be if there was an annotation that I could add to the Controller classes that would turn them into JSON serv

Spring 3与MVC的JSON

有没有办法建立分别使用和生成application/json格式的请求和响应的Spring Web调用? 也许这不是Spring MVC,我不确定。 我正在寻找与Jersey / JSON类似的Spring库。 最好的情况是,如果有一个注释可以添加到控制器类中,并将它们转换为JSON服务调用。 展示如何使用JSON构建Spring Web Services的教程会很棒。 编辑:我正在寻找一种基于注释的方法(类似于泽西岛)。 EDIT2:像Jersey一样,我正在寻找REST支持(POST,G

Curl not working for HTTP Post to Spring

I have a RequestMapping setup in a spring @Controller and I am unable to correctly send a CURL request to it. I keep getting a HTTP 400 return code when trying to send various ways. I am not sure what is setup incorrectly. Here is the request curl -v -X POST localhost:8082/api/registerDevice -d '{"serial":"FA541YJ05065"}' -H "Content-Type:application/json;charset=UTF-8" Here is the output

Curl不适用于HTTP Post到Spring

我在Spring @Controller有一个RequestMapping设置,我无法正确地向它发送一个CURL请求。 尝试发送各种方式时,我不断收到HTTP 400返回码。 我不确定什么设置不正确。 这是请求 curl -v -X POST localhost:8082/api/registerDevice -d '{"serial":"FA541YJ05065"}' -H "Content-Type:application/json;charset=UTF-8" 这是输出 Note: Unnecessary use of -X or --request, POST is already inferred. * Trying ::1... * C

Spring 3.0 making JSON response using jackson message converter

i configure my messageconverter as Jackson's then class Foo{int x; int y} and in controller @ResponseBody public Foo method(){ return new Foo(3,4) } from that im expecting to return a JSON string {x:'3',y:'4'} from server without any other configuration. but getting 404 error response to my ajax request If the method is annotated with @ResponseBody, the return type i

Spring 3.0使用杰克逊消息转换器进行JSON响应

我把messageconverter配置成Jackson的那个 class Foo{int x; int y} 并在控制器中 @ResponseBody public Foo method(){ return new Foo(3,4) } 从那个im期望返回一个JSON字符串{x:'3',y:'4'}从服务器没有任何其他配置。 但获取404错误响应我的ajax请求 如果该方法使用@ResponseBody进行注释,则返回类型将写入响应HTTP主体。 使用HttpMessageConverters将返回值转换为声明的方法参数类型。 我错

validate individual request params

I'm running a webapp in Spring Web MVC 3.0 and I have a number of controller methods whose signatures are roughly as follows: @RequestMapping(value = "/{level1}/{level2}/foo", method = RequestMethod.POST) public ModelAndView createFoo(@PathVariable long level1, @PathVariable long level2, @RequestParam("foo_name") String fooname, @RequestParam(value = "description", re

验证个别请求参数

我在Spring Web MVC 3.0中运行一个webapp,我有一些控制器方法,其签名大致如下: @RequestMapping(value = "/{level1}/{level2}/foo", method = RequestMethod.POST) public ModelAndView createFoo(@PathVariable long level1, @PathVariable long level2, @RequestParam("foo_name") String fooname, @RequestParam(value = "description", required = false) String description); 我想添加一些验

Which Spring Framework provides REST Services?

This question already has an answer here: Spring 4.x/3.x (Web MVC) REST API and JSON2 Post requests, how to get it right once for all? 2 answers You don't need a Framework to implement REST Services with Spring, it's just a possibile way to how you can implement Services in Spring. As the official doc Spring - Creating RESTful services says: Spring's annotation-based MVC fram

哪个Spring Framework提供了REST服务?

这个问题在这里已经有了答案: Spring 4.x / 3.x(Web MVC)REST API和JSON2 Post请求,如何正确使用它? 2个答案 你不需要一个框架来使用Spring来实现REST服务,它只是一个可以让你在Spring中实现服务的方法。 正如官方文档Spring - 创建RESTful服务所说: Spring基于注释的MVC框架是创建RESTful Web服务的基础。 所以,如果你没有添加spring-web & spring-webmvc依赖项到你的项目中,这可能是你必须做的事情。

Performance comparison of Thrift, Protocol Buffers, JSON, EJB, other?

We're looking into transport/protocol solutions and were about to do various performance tests, so I thought I'd check with the community if they've already done this: Has anyone done server performance tests for simple echo services as well as serialization/deserialization for various messages sizes comparing EJB3, Thrift, and Protocol Buffers on Linux? Primarily languages will b

Thrift,Protocol Buffers,JSON,EJB等性能比较?

我们正在研究运输/协议解决方案,并且正在进行各种性能测试,所以我认为如果他们已经这样做,我会与社区进行核对: 有没有人为简单的echo服务做过服务器性能测试,以及比较各种消息大小的序列化/反序列化,比较Linux上的EJB3,Thrift和Protocol Buffers? 主要的语言将是Java,C / C ++,Python和PHP。 更新:我仍然非常感兴趣,如果有人已经做了任何进一步的基准,请让我知道。 此外,非常有趣的基准测试显示压缩JSON的

Where does Gradle managed dependency without Maven or Ivy?

I understand that usually Java projects using Gradle are publishing their reusable code by publishing the Maven's pom.xml file along side with the jar file. However I'm wondering where Gradle store the dependency list if the library is not published using neither Ivy nor Maven. Moreover, Gradle can be used not only for JVM-based project, but it can also be used to build non-JVM project,

Gradle在没有Maven或Ivy的情况下如何管理依赖关系?

我知道通常使用Gradle的Java项目通过将Maven的pom.xml文件与jar文件一起发布来发布其可重用代码。 然而,我想知道如果库不是使用Ivy和Maven发布的,Gradle将依赖列表存放在哪里。 而且,Gradle不仅可以用于基于JVM的项目,还可以用于构建非JVM项目,这显然不使用Maven或Ivy。 我已经阅读过第23章依赖管理,但它没有提供Gradle如何在没有Maven或Ivy的情况下发布Java库的线索。 从Gradle 2.13开始,Gradle中的本地项目的传递