将参数传递给 JSF 操作 [英] Passing parameter to JSF action
本文介绍了将参数传递给 JSF 操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 GlassFish 3.1,并尝试将参数传递给 commandButton 操作.以下是我的代码:
beans.xml
faces-config.xml
ManagedBean 类
package actionParam;导入 javax.enterprise.context.RequestScoped;导入 javax.inject.Named;@Named("bean")@RequestScoped公共类 ActionParam {公共动作参数(){极好的();}公共字符串提交(int param){System.out.println("使用值提交" + param);返回空;}}
最后,
查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"xmlns:h="http://java.sun.com/jsf/html"xmlns:f="http://java.sun.com/jsf/core"><h:头><meta http-equiv="内容类型"content="text/html; charset=ISO-8859-1"/><title>测试动作参数</title></h:head><h:body><h:form id="actionForm"><h:commandButton id="actionButton" value="提交"action="#{bean.submit}"><f:param name="param" value="123"></f:param></h:commandButton></h:form></h:body>