我努力解决这个问题
我有两个xhtml页面索引页
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:link value="Go to page2" outcome="response">
<f:param name="field1" value="firstvalue" />
<f:param name="field2" value="secondvalue" />
<f:param name="field3" value="thirdvalue" />
</h:link>
</h:body>
</html>
和回复页
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<f:metadata>
<f:viewParam name="field1" value="#{bean2.field1}"/>
<f:viewParam name="field2" value="#{bean2.field2}"/>
<f:viewParam name="field3" value="#{bean2.field3}"/>
</f:metadata>
<h:outputText value="#{bean2.field1}" />
<h:outputText value="#{bean2.field2}" />
<h:outputText value="#{bean2.field3}" />
</h:body>
</html>
并且只有一个bean
@Named(value = "bean2")
@SessionScoped
public class Bean2 implements Serializable{
private String field1;
private String field2;
private String field3;
//...... getters and setters
}
当我点击索引页面中的链接时,它会导航到响应页面但不设置字段值
你有什么建议为什么不起作用?
注意:我正在使用glassfish 4.0
谢谢...
答案 0 :(得分:2)
通过更改名称空格来解决
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">