返回错误消息“服务器发送了空响应”

问题描述 投票:-1回答:1

以下是我的JSF代码

<h:input type="newDate">

<h:commandLink>
<f:ajax execute="newDate" listener="myBean.getResultByNewDate()">
</h:commandLink>

在备用bean中,将newDate字段定义为Date,并且还定义了getResultByNewDate()方法。但是单击命令链接后,出现错误消息:“服务器发送了空响应”。

我需要在getResultByNewDate()中使用newDate的值。有关解决此问题的任何建议。语法正确吗?

jsf
1个回答
0
投票

您的JSF代码有多个问题:

1)input应替换为inputText。2)type在这里也没有用。3)listener应该使用适当的绑定。4)execute应该使用需要在ajax上执行的xhtml组件的id

代码应类似于:

<h:inputText value="#{myBean.newDate}" id="dateInput">

<h:commandLink>
<f:ajax execute="dateInput" listener="#{myBean.getResultByNewDate()}">
</h:commandLink>

要特别注意的是,如果您要用commandButton代替commandLink,则应声明type="button",否则将面临ajax的问题​​。因为ajax的类型为button,并且commandButton的默认类型为submit,而commadLink的默认类型为button

© www.soinside.com 2019 - 2024. All rights reserved.