尝试显示数据库中的值而不使用JQuery和Ajax刷新网页成功显示了此内容,但是“ Served at:/ Project name”已附加到显示的值中
脚本:
$(document).ready(function() {
$('#AESASJOBRUNOPTION').change(function() {
var AESASJOBRUNOPTION = $('#AESASJOBRUNOPTION').val();
$.ajax({
type:'POST',
url: "AESASJobCurrentOpenPeriod",
data: {AESASJOBRUNOPTION: AESASJOBRUNOPTION},
cache: false,
success: function(result) {
$("#result1").html(result);
$("#result1").html(result).slideDown('slow');
}
});
});
});
Servlet:
try{
if(ASCOGSRS.next()){
//System.out.println("Open Peiod is :"+ASCOGSRS.getString(1));
HttpSession OpenPeriodsession=request.getSession();
OpenPeriodsession.setAttribute("ASCOGSCurrentOpenPeriod", ASCOGSRS.getString(1));
PrintWriter out =response.getWriter();
String ASCOGSOpenPeriod=ASCOGSRS.getString(1);
out.print(" The Current Open Period is: "+ASCOGSOpenPeriod);
}
}
最佳答案
如果您的项目使用的是Eclipse中的JET Template,则看起来doPost
方法appends是额外的Served at: <PATH>
。
如果使用JET模板,则可能是以下解决方案:
在Eclipse Window -> Preferences -> Java EE
中使用JET模板跳过
如果无法跳过JET模板,并且您的AJAX请求仅检索数据,请将请求类型更改为GET
而不是POST
如果未使用JET模板,则以下是Javascript级别的解决方案:
$(document).ready(function() {
$('#AESASJOBRUNOPTION').change(function() {
var AESASJOBRUNOPTION = $('#AESASJOBRUNOPTION').val();
$.ajax({
type:'POST',
url: "AESASJobCurrentOpenPeriod",
data: {AESASJOBRUNOPTION: AESASJOBRUNOPTION},
cache: false,
success: function(result) {
result_without_path = result.replace(/Served at:[\/a-zA-Z0-9]*/i,'');
$("#result1").html(result_without_path);
$("#result1").html(result_without_path).slideDown('slow');
}
});
});
});
关于java - 项目名称被追加到输出编写器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32649183/