spring mvc annotation @RequestAttribute similar to

2019-08-12 15:32发布

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

2条回答
混吃等死
2楼-- · 2019-08-12 15:41

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

查看更多
仙女界的扛把子
3楼-- · 2019-08-12 15:55

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/

查看更多
登录 后发表回答