springmvc
@RequestMapping(value = { "createHtml" })
@ResponseBody
public String getCreateHtml(HttpServletRequest request,
HttpServletResponse response, Model model) {
String web = request.getParameter("web");
String url = request.getParameter("url");
String type = request.getParameter("type");
if (web.equals("tool")) {
String path = "";
if (type.equals(HtmlUtil.INDEX)) {
// 生成tool首页
// 项目跟路劲
path = Global.getCreatePath() + File.separator + "index.html";
return createHtmlUtil.toolIndex(url, path);
}
if (type.equals(HtmlUtil.MENU)) {
// 菜单
path = Global.getCreatePath() + HtmlUtil.TOOL_MENU_PATH;
return createHtmlUtil.toolOther(url, path);
}
if (type.equals(HtmlUtil.RIGHT)) {
// 推荐页面
path = Global.getCreatePath() + HtmlUtil.TOOL_TUIJIAN_PATH;
return createHtmlUtil.toolOther(url, path);
}
}
return "请联系管理员进行配置。。";
}
ajax
function getCreateHtml(url,type,web){
$.ajax({
url : 'createHtml',
data : {
"url": url,
"type":type,
"web":web
},
cache : false,
async : false,
type : "POST",
success : function (data){
alertx(data);
}
});
}
注意点在于返回值。。
当ajax 设置 为 json 返回的时候
相应要加上
@RequestMapping(value = “/collectionQuestion.php”,produces = “application/json; charset=utf-8”)