我在JSP做了一个表格说first.jspAjax和RequestDispatcher的工作不
<input type="radio" name="actionType" value="edit_notice" class="noticeaction">Edit
<input type="radio" name="actionType" value="delete_notice" class="noticeaction">Delete
<input type="radio" name="actionType" value="post_notice" class="noticeaction">Post Notice
<br/><br/><br/>
<input type="submit" name="reviewNoticeSubmit" value="Submit" id="reviewNoticeSubmit">
jQuery的在Ajax调用是:
else if(actionToPerform == "edit_notice")
{
var noticeId = $(".selectednotice").val();
var param = "noticeId=" + noticeId;
jQuery.ajax({
type:"POST",
url : "reviewnoticeaction/editnotice",
data : param,
beforeSend : function() {
},
complete : function() {
},
success : function(data) {
},
error : function(xmlHttpRequest, textStatus, errorThrown) {
alert("Error occured. Unable to open editor");
}
});
}
以下是servlet代码得到来自数据库的一些值和分配给属性,我试图将其转发到另一个jsp页面。它不工作。
request.setAttribute("firstData", editNoticeRs.getString("firstData"));
request.setAttribute("secondData", editNoticeRs.getDate("secondData"));
request.setAttribute("thirdData", editNoticeRs.getDate("thirdData"));
RequestDispatcher rd = request.getRequestDispatcher("second.jsp");
rd.forward(request, response);
PS:在情况下,如果我不能也有可能转发给另一个JSP得到的数值在同一个jsp页面和访问的价值?如果是的话如何?
jQuery的'ajax'方法是HTTP返回JSON或字符串datat回到阿贾克斯成功处理程序客户在自己的权利。它可以发送请求并接收响应。它收到的回复与您目前正在浏览的浏览器页面无关。 –