SpringMvc Error:java.lang.IllegalStateException

Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>

Code:

public @ResponseBody Object getCommonInfo(HttpServletRequest request, HttpServletResponse response) {
        Map<String, String[]> parameterMap = request.getParameterMap();
        String[] timeArray = { System.currentTimeMillis() + "", };
        parameterMap.put("timeStamp", timeArray);
        fluentLogSender.sendLog2("Appstore", parameterMap);
        ResponseUtils.writeResponse(response, ErrorResponse.getEmptyResult());
        return null;
    }

The exception thrown is:

java.lang.IllegalStateException: No modifications are allowed to a locked ParameterMap
	at org.apache.catalina.util.ParameterMap.put(ParameterMap.java:164)
	at com.hisense.hitv.appstoreapi.controller.AppAdversingController.getCommonInfo(AppAdversingController.java:104)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
        …………

This is because the map obtained through request. Getparametermap() is not allowed to be modified( I don’t know why ~ ~)

The solution is to create a new map to receive the value of request. Getparametermap()

Direct assignment is an address reference, and no new memory space is allocated. You can apply for a new memory address by using the New method, and the value of map can be modified

Similar Posts: