【发布时间】:2014-06-25 16:13:03
【问题描述】:
我有一个非常复杂的场景,我需要从 jquery get Request 更改 java 对象(基本上是 HashMap )并获取响应并在 jsp 中打印出来。用户可以根据请求发送请求数量并从 servlet 获得单独的响应并显示数据。
在每次请求之后,我必须将地图放入会话中,而不是在另一个请求中,我在会话中得到相同的结果并进行更新并将其放回会话中。
JqueryGet(parameter) to Java.
Updating Hashmap according to parameter.
Putting hashmap in session . ( session.setAttribute("map",map))
sending response back to Jsp in jquery and print results in jsp.
Than another request send to Java .
it will get the map from session session.getAttribute("map",map) and than update the map based on new request .
Put the map again in session and so on....Than i have a submit button finally which will show the new data on the page and than update the server.
这是正确的方法吗?到目前为止,我的功能在开发环境中运行良好。但我担心我是否应该使用 DOM。如果我将使用 DOM,它将非常复杂,因为我必须根据请求操作 Hashmap 的许多值。
这里是jquery代码:
$.ajax({
url: '<%=portalContext.createTemplateProcessURI()%>'
+'?s1='+ $("#networkBox1").val()+'&box1=Box1&tick=add&val1='+ allvs+'&s2='+ $("#networkBox2").val()+'&box2=Box2&val2='+ allvs,
type: 'get',
dataType: 'text',
async: false,
success: function(data) {
Processbox(data); // This function displaying the result.
}
});
【问题讨论】:
标签: java jquery json dom servlets