@RequestMapping(params = "method=buildtemplate",method = RequestMethod.GET)
public ModelAndView listFormField(String funcId, int fmtId){
        ModelAndView mav = new ModelAndView("/ws/listformfields");
        List<SysFuncformapcolumn> fmcs = this.formManagerService.getColumnInfo(fmtId);    //读取相应的数据库映射信息
        Gson gson=new Gson();
        String json_txt = gson.toJson(fmcs);
        mav.addObject("json_data", json_txt);
        return mav;
    }

能实现目标但很麻烦,查了查网络,原来有简洁的写法:)
@ResponseBody        //用了此注释就不需要单独再建立一个jsp文件作为ajax调用的模板了:)
@RequestMapping(params = "method=buildtemplate",method = RequestMethod.GET)
public String listFormField(String funcId, int fmtId){
        List<SysFuncformapcolumn> fmcs = this.formManagerService.getColumnInfo(fmtId);
        Gson gson=new Gson();
        String json_txt = gson.toJson(fmcs);
        return json_txt;
    }

这样的确很方便,省去了创建一个jsp文件。很简洁

相关文章:

  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2021-06-10
  • 2022-12-23
猜你喜欢
  • 2021-12-12
  • 2021-07-27
  • 2021-10-28
  • 2021-06-05
  • 2021-08-03
  • 2021-07-10
相关资源
相似解决方案