//后台
public String toQuestionType()
{try
{
exambankList=examitembankService.QuestionList();
List<Object []> list = exambankList;
String json="[";
String Countent="";
for (Object[] objects : list) {
Countent+="{\"id\":\""+objects[0]+"\",\"QuestestName\":\""+objects[1]+"\",\"Questemplate\":\""+objects[2]+"\"},";
}
json =(json+Countent).substring(0, (json+Countent).lastIndexOf(","))+"]";
setJsonstr(json);
}
catch(Exception e) {
e.printStackTrace();
setReturnCode("error");
setReturnMsg("绑定题型失败!");
// TODO: handle exception
}
return "toQuestionType";
}
//js
function queryTerms() {
$.post("Examitembank_toQuestionType", null, function(data) {
//绑定题型点信息
$("#s_questiontype").append("<option value=\"0\">" + '--请选择--' + "</option>");
var jsonData=eval("("+data.jsonstr+")");
for(var key in jsonData)
{
$("#s_questiontype").append("<option value=\""+jsonData[key].Questemplate+"\">" + jsonData[key].QuestestName + "</option>");
}
});
}
//只能填写数字
οnkeyup="value=value.replace(/[^\d]/g,'')"
//只填写字母和数字
οnkeyup="value=value.replace(/[^\w\.\/]/g,'')"
forward方式:request.getRequestDispatcher("/somePage.jsp").forward(request, response);
redirect方式:response.sendRedirect("/somePage.jsp");
forward是服务器内部重定向,程序收到请求后重新定向到另一个程序,客户机并不知道;redirect则是服务器收到请求后发送一个状态头给客户,客户将再请求一次,这里多了两次网络通信的来往。当然forward也有缺点,就是forward的页面的路径如果是相对路径就会有些问题了