jeecms后台中怎样使用ajax,试着写了个说访问拒绝
package com.jeecms.cms.action.admin.assist;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.
JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.jeecms.cms.entity.assist.CmsCompanydata;
import com.jeecms.cms.manager.assist.CmsCompanydataMng;
import com.jeecms.common.web.ResponseUtils;
@Controller
public class CmsCompanydataAct {
private static final Logger log = LoggerFactory
.getLogger(CmsCompanydataAct.class);
@RequestMapping(value = "/getajax.do", method = RequestMethod.POST)
public void getajaxf(String div, String id,
HttpServletRequest request,
HttpServletResponse response) throws JSONException {
JSONObject json = new JSONObject();
String getstr = cmsCompanydMng.findit(div,id);//member
json.put("regnum", getstr);
//json.put("domain", site.getDomain() );
ResponseUtils.renderJson(response, json.toString());
return;
}
@Autowired
private CmsCompanydataMng cmsCompanydMng;
}
//////////////////////////////////////////////////////////////////////js
if($("#zregnum").length>0){
var id=$("#regnum").attr("value");
$.post("../getajax.do",{div:"zch",id:id},function(data){
var obj = JSON.parse(data);
if(obj.regnum == ""){
$("#zregnum").html("<span style='color:red;'>没有查询到注册号!</span>");
}
});
}
POST http://localhost:8080/jeecms/admin/getajax.do 403 Forbidden
是否和web.xml的访问地址过滤设置有关
------解决方案--------------------http://localhost:8080/jeecms/admin/getajax.do 可以访问不? 换浏览器呢 。