JSF 2.0 + Spring 3,通过注解检索请求参数

发布于 2024-12-13 03:59:59 字数 290 浏览 1 评论 0原文

在本机 JSF 2.0 环境中,用户可以使用类似的内容引用请求参数。

@ManagedProperty("#{param.id}")
private Long id;

但是,我使用 Spring 来管理 JSF bean,因此在我的情况下,@ManagedProperty 注释被忽略。仍然可以在 faces-config.xml 中使用 #{param.id} 语句,但基于注释的配置显然更可取。

有没有办法用Spring注解来解决这样的语句?

In native JSF 2.0 environment user is able to refer to request parameters with something like

@ManagedProperty("#{param.id}")
private Long id;

However I'm using Spring to manage JSF beans, so @ManagedProperty annotation is ignored in my case. It's still possible to use #{param.id} statement in faces-config.xml, but annotation-based configuration is obviously much more preferable.

Is there any way to resolve such statements with Spring annotations?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

看透却不说透 2024-12-20 03:59:59

您可以尝试将 @Value 与 Spring 表达式语言一起使用。应该有可用的 request 变量:

@Value("#{request.getParameter('id')}")
private Long id

You can try to use @Value with Spring Expression Language. There should be request variable available:

@Value("#{request.getParameter('id')}")
private Long id
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文