model view controller - spring mvc @requestmapping best practice -


checked official ref, found million ways things.
guess have 2 set of use cases. 1. return customized http response, responsible filling in status code, response body(either xml or json or text). 2. return model , view. view jsp page typically , fill in view data modle.

my question better way go? possible mix them together. in first use set, possible return view? possible have both on them in 1 method. if return customized http response, if b return modelandview.

thanks!

the return value request handling method (i.e. on marked @requestmapping annotation must either identify view (that generate http response) or generate http response itself.

each handler method stands alone; mean, can return view name handler methods , generate http response in other handler methods.

check out 15.3.2.3 supported handler method arguments , return types in spring 3x reference document @ http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/

as option generating http response in handler method, setup multiple view resolvers; 1 or more normal view resolution (jsp pages, tiles, etc.) , 1 or more "special" view resolution (xml, json, etc.). "special" views, may want create own view class extends org.springframework.web.servlet.view.abstractview.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -