$.ajax({
url:"${path}/路径",
data:{"company":company },
type:"POST",
success:function(data){
var cer = data.certificate;
}
});
public void test(){
PrintWriter out=null;
HttpServletRequest request = ServletActionContext.getRequest();
try {
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("application/json;charset=gbk");
out = response.getWriter();
String company = request.getParameter("company");
int companyId = Integer.valueOf(company).intValue();
Company comData = companyService.selectSecretKeyByCompanyId(companyId);
String json = JSON.toJSONString(comData);
out.write(json);
} catch (Exception e) {
e.printStackTrace();
}finally{
if(out!=null){
out.flush();
out.close();
}
}
}
/*
前台data获取到的数据为[object object]对象,所以解析出来想要的数据,直接data.对象.
*/
success:function(data){
var cer = data.对象(key);
}