spring mvc中有一个注解:@ResponseBody,把这个注解放到ajax请求对应的@RequestMapping(xxx)方法上,在方法体内部,把要返回的json赋给一个String类型的变量,然后return这个变量即可,例子如下:

        @ResponseBody  
    @RequestMapping("/show")
    public String show(Map<String,Object> map,String username){
        System.out.println("----enter show method");
        RepositoryService rs = processEngine.getRepositoryService();
        ExecutionService es = processEngine.getExecutionService();
        TaskService ts = processEngine.getTaskService();
        List<ProcessDefinition> liststemp = rs.createProcessDefinitionQuery().list();
        List<PD> lists=toJsonList.processDefine2PD(liststemp)
        Gson gson=new Gson();
        String str=gson.toJson(lists);
        
        return str;
@ResponseBody  
	@RequestMapping("/show")
	public String show(Map<String,Object> map,String username){
		System.out.println("----enter show method");
		RepositoryService rs = processEngine.getRepositoryService();
		ExecutionService es = processEngine.getExecutionService();
		TaskService ts = processEngine.getTaskService();
		List<ProcessDefinition> liststemp = rs.createProcessDefinitionQuery().list();
		List<PD> lists=toJsonList.processDefine2PD(liststemp)
		Gson gson=new Gson();
		String str=gson.toJson(lists);
		
		return str;

  

 

相关文章:

  • 2021-08-19
  • 2022-12-23
  • 2021-07-24
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-05-02
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
相关资源
相似解决方案