當我的網頁發生更改時,我試圖填充兩個單獨的HTML對象 - 一個下拉列表和一個表單。通過Java填充多個HTML語句從Javascript更改
所以在我的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
似乎只允許我爲每個更改填充一個對象。
對不起,我的意思是從一個JSP頁面。好的,謝謝你的帖子。但它如何知道html的哪個部分是用於ulist的,哪些是用於某些元素的? – maloney 2013-03-06 10:01:33