【发布时间】:2013-03-06 12:05:37
【问题描述】:
我正在尝试根据 Java 的结果找到一种在 JSP 页面中填充“表单”的方法。
这是我的 Javascript 代码:
$('#uSystemList').change(function() {
$.get("/live-application/systemById", {systemid: $("#uSystemList").val()}, displayChangedSystemResults, "html");
});
function displayChangedSystemResults(html){
$('#systemForm').empty();
$('#systemForm').append(html);
}
形式:
<form:form id="systemForm" method="post" action="/live-application/systemSave" commandName="systemForm">
<tr>
<td valign="top"><form:select path="uSystemList" id="uSystemList"> </form:select> </td>
</tr>
<tr>
<td valign="top"><form:input path="fSystemName"/></td>
</tr>
</form:form>
还有 Java 方面:
@RequestMapping(value = "/systemById", method = RequestMethod.GET)
public void getSystemById(@RequestParam("systemid") String systemid, OutputStream outputStream) throws IOException {
StringBuilder refreshHtml = new StringBuilder();
try {
String html = new String();
if (!systemid.equals("")) {
System system = service.getSystemById(systemid));
html = html + "<input type='text' value='" + system.getName() + "' id='fSystemName' />";
}
refreshHtml.append(hostHtml);
outputStream.write(refreshHtml.toString().getBytes());
outputStream.flush();
} catch (Exception e) {
outputStream.flush();
}
}
作为测试,我只想填充表单的fSystemName 字段,但当它返回displayChangedSystemResults 函数时没有任何反应。谁能发现我做错了什么?
【问题讨论】:
-
form:select可能应该以>结束,而对于form:input则缺少/> -
抱歉,这是一个错误,因为我从中删除了很多代码。我现在要编辑...