JSF:如何在操作方法的返回字符串中包含参数? [英] JSF: How do I include parameters in an action method's return string?

查看:93
本文介绍了JSF:如何在操作方法的返回字符串中包含参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个将新对象存储在数据库中的操作方法.完成此操作后,我要导航以查看该新创建的对象.为此,我计划在action方法的返回String中包含一个querystring或某种类型的参数,但是我不知道怎么做.如果我手动附加查询字符串,它似乎被忽略了.另外,通过串联字符串手动添加参数在我看来也不是一个好主意.可以以类型安全的方式执行此操作吗?

I'm writing an action method that will store a new object in a database. Once this is done, I want to navigate to view that newly created object. To do this, I was planning to include a querystring or some sort of parameter in the return String of the action method, but I can't figure out how. If I append a query string manually, it appears that it's being ignored. Also, manually adding parameters by concatenating strings doesn't seem like a good idea to me. Is it possible to do this in a type-safe manner?

推荐答案

我一直处理此问题的方法是获得对bean的引用,该bean提供将要显示的页面的内容,并对其进行设置属性.从操作方法返回的导航字符串不是用于传递参数的,但您不需要这样做.它们将被用来设置bean属性.

The way I've always handled this is to get a reference to the bean which provides the content for the page you'll be displaying, and just set its properties directly. The navigation string returned from an action method isn't meant for passing parameters, but you don't need it to; all they'd be used for is setting bean properties anyway.

这篇关于JSF:如何在操作方法的返回字符串中包含参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆