Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Session JSF新网站创建_Session_Jsf - Fatal编程技术网

Session JSF新网站创建

Session JSF新网站创建,session,jsf,Session,Jsf,我有一个JSF项目,我已经有了一个index.xhtml页面,它运行良好。当我尝试添加另一个XHTML页面时,由于某种原因,它没有连接到会话范围的托管bean。我在新页面中添加了代码,但它的工作方式与我的index.xhtml不同。我甚至从索引中复制并粘贴了代码,但它仍然不起作用。有什么想法吗 以下是我在新页面中的一些代码: Amount: <h:inputText value="#{transactionBean.amount}" style="color: Yellow; backgr

我有一个JSF项目,我已经有了一个
index.xhtml
页面,它运行良好。当我尝试添加另一个XHTML页面时,由于某种原因,它没有连接到会话范围的托管bean。我在新页面中添加了代码,但它的工作方式与我的
index.xhtml
不同。我甚至从索引中复制并粘贴了代码,但它仍然不起作用。有什么想法吗

以下是我在新页面中的一些代码:

Amount: <h:inputText value="#{transactionBean.amount}" style="color: Yellow; background: Teal;"/>
Price <h:inputText value="#{transactionBean.pricePaid}" style="color: Yellow; background: Teal;"/
从评论中:

faces servlet未处理您的第二个页面。Facesservlet的url模式是
/faces/*
。因此,所有请求都必须包含前缀
/faces
,才能被servlet处理

如果您使用以下URL调用您的页面,它应该可以工作:


您已经将faces servlet映射到
/faces/*
而不是
*.xhtml
。这意味着您需要在URL中包含
/faces
路径,以运行faces servlet

因此,您不应该通过

而是

然而,更好的方法是只使用
*.xhtml
作为FacesServlet的URL模式,这样就不需要修改虚拟路径

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
</welcome-file-list>

Facesservlet
javax.faces.webapp.FacesServlet
1.
Facesservlet
*.xhtml
index.xhtml

(请注意,30分钟的
已是默认值,只需将其删除即可)

请具体说明。什么“不起作用”?browser或server.log中有错误吗?没有呈现html?没有错误它不显示任何内容它不显示任何内容。页面上只显示金额和价格。没有输入文本或其他原因可能是第二个页面没有被Facesservlet处理。浏览器中的源代码是什么?可能是,但如何解决此问题?浏览器的url显示“”我是指浏览器中的html源代码(右键单击-->查看源代码)。也许您必须调整web.xml中的facesservlet映射。你能发布web.xml吗?
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
</welcome-file-list>