Java f:param和ManagedProperty-如何设置faces-config.xml
我正在尝试创建一个commandLink来显示关于对象的更多细节(我在foreach标记中) 这是我的faces-config.xmlJava f:param和ManagedProperty-如何设置faces-config.xml,java,jsf,javabeans,param,Java,Jsf,Javabeans,Param,我正在尝试创建一个commandLink来显示关于对象的更多细节(我在foreach标记中) 这是我的faces-config.xml <managed-bean> <managed-bean-name>controller</managed-bean-name> <managed-bean-class>html.controller.Controller</managed-bean-class> <managed-bean-sc
<managed-bean>
<managed-bean-name>controller</managed-bean-name>
<managed-bean-class>html.controller.Controller</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
<property-class>Long</property-class>
<value>#{param.id}</value>
</managed-property>
</managed-bean>
为什么??我想我没有在faces config xml中很好地设置属性名,所以我应该在其中添加什么?可能重复我没有使用viewParam。。。我想知道我应该在faces-config.xml上添加什么,另一个代码肯定是正确的。请尝试将托管bean的作用域更改为
@requestscope
。我建议只使用注释功能,并放弃faces-config.xml
文件。然后再次清理、构建和运行项目。
@ManagedBean
public class Controller {
@ManagedProperty(value="#{param.id}")
private Long id;
private String name;
private Product product;
....
public String findProduct() {
this.product = facade.getProduct(id);
return "details";
}
<managed-bean>
<managed-bean-name>controller</managed-bean-name>
<managed-bean-class>html.controller.Controller</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>id</property-name>
<property-class>Long</property-class>
<value>#{param.id}</value>
</managed-property>
</managed-bean>
Property id references object in a scope with shorter lifetime than the target scope session