【发布时间】:2013-02-21 01:06:38
【问题描述】:
当我的网页发生更改时,我试图填充两个单独的 HTML 对象 - 一个是下拉列表,一个是表单。
所以在我的 JSP 代码中我有这个:
$('#uSystemList').change(function() {
$.get("/live-application/systemById", {systemid: $("#uSystemList").val()}, displayChangedSystemResults, "html");
});
<script type="text/javascript">
function displayChangedSystemResults(html){
$('#uList').empty();
$('#uList').append(html);
}
</script>
在 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 = "";
System system = service.getSystemById(systemid));
for (Value value: inewsSystem.getValues()) {
html = html + "<option value='" + value.getId() + "'> " + value.getName() + "</>";
}
}
refreshHtml.append(html );
outputStream.write(refreshHtml.toString().getBytes());
outputStream.flush();
} catch (Exception e) {
outputStream.flush();
}
}
这样会填充我的uList 下拉列表 - 但我如何告诉它也填充其他内容(例如表单,但可以是其他任何内容作为示例......)。 OutputStream 似乎每次更改只允许我填充一个对象。
【问题讨论】: