Error to return JSON response for Spring MVC Post request to multiple user

问题内容:

I have the below controller method preparing a json response to jQgrid after a submit search request. No problem with Request/response if just one user works on search form but, it being abnormal when more than one user works simultaniously on the search form, the method render the response of the last search sended to the server =>As the result, the user 1 get the response of the second search by user 2.

Map<String,Csvfilecontent> searchForm = new HashMap<String,Csvfilecontent>();    
@RequestMapping(value="/submitsearchUmsatz", produces="application/json")
@ResponseBody
public JqgridResponse<Csvfilecontent> submitsearchUmsatz(HttpServletRequest request,
        @RequestParam(value="page", required=false) Integer page,
        @RequestParam("_search") Boolean search,
        @RequestParam(value="filters", required=false) String filters,
        @RequestParam(value="rows", required=false) Integer rows,
        @RequestParam(value="sidx", required=false) String sidx,
        @RequestParam(value="sord", required=false) String sord) throws ParseException
    {
    Pageable pageRequest = new PageRequest(page-1, rows );
    JqgridResponse<Csvfilecontent> response = new JqgridResponse<Csvfilecontent>();
    if (search == true) {
        return getFilteredRecords(filters, pageRequest);

    } 
    Page<Csvfilecontent> contentPage =  searchForm.isEmpty()? null :serv.findBySearchTermsForm(searchForm.get("entity"),pageRequest);
    List<Csvfilecontent> contentmapped = CsvContentMapper.map(contentPage);
    response.setRows(contentmapped);
response.setRecords(Long.valueOf(contentPage.getTotalElements()).toString());
response.setTotal(Integer.valueOf(contentPage.getTotalPages()).toString());
response.setPage(Integer.valueOf(contentPage.getNumber()+1).toString());
return response;}

Could you please help me to know where is my error.

问题评论:

原文地址:

https://stackoverflow.com/questions/47755926/error-to-return-json-response-for-spring-mvc-post-request-to-multiple-user

添加评论

友情链接:蝴蝶教程