spring mvc annotation @RequestAttribute similar to @RequestParam

ぃ、小莉子 提交于 2019-12-24 06:58:12

问题


I would like add an annotation similar to @RequestParam, though have it pull the values from the request attribute rather than the request param...

Is there an example or explanation how to create my own annotation for this and the handler / binder needed as well?

Thanks


回答1:


The blog entry with the title "Extending Spring MVC's annotation controller" answers your question. Google it to find it since Stackoverflow won't let me create the direct link.

Basically you create an @RequestAttribute annotation and then a custom WebArgumentResolver.

The blog entry has examples for @RequestAttribute and @SessionAttribute.

The svn directory with the examples is here.

http://impala-extensions.googlecode.com/svn/trunk/impala-extension-mvc/src/org/impalaframework/extension/mvc/




回答2:


Since Spring 4.3 @RequestAttribute annotation is a part of Spring MVC, so there is no need to create your own @RequestAttribute annotation



来源:https://stackoverflow.com/questions/1263941/spring-mvc-annotation-requestattribute-similar-to-requestparam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!