1

I am kind of new to spring MVC and I wanted to use JasonViews (Jackson) for dynamic JSON per request and I didn't want to change my controllers too much .. so @marty here gave me a great solution in his blog

http://martypitt.wordpress.com/2012/11/05/custom-json-views-with-spring-mvc-and-jackson/

The problem is that I need control over the HTTP status codes,so my controllers are returning types of HttpResponse{T} and not List{T} how can I customize the code in order to support parsing of types like HttpResponse{List{Book}}?

If not possible, can I control the Http status code without the HttpResponse?

Elnur Abdurrakhimov
  • 44,533
  • 10
  • 148
  • 133
assaf_miz84
  • 687
  • 2
  • 15
  • 33

1 Answers1

0

I may need to see an example of your code to really understand what you are asking, but this might point you in the right direction:

Take @marty's code and try extending HttpEntityMethodProcessor with it.

http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.htmlS

Then, you need to make your method signatures look like

public ResponseEntity<MyType> getMyTypeWithControlOverResponseEntity(...) {...}

You can find more info on this signature type at:

http://static.springsource.org/spring/docs/current/spring-framework-reference/htmlsingle/#mvc-ann-httpentity

Let me know if this is not the right direction you were trying to go or need more help. =)

MattSenter
  • 3,060
  • 18
  • 18