dimanche 23 octobre 2016

Spring set method parameter fields via reflection in Interceptor

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        MethodParameter methodParameter = ((HandlerMethod) handler).getMethodParameters()[0];
        for (Field field : ((Class) methodParameter.getGenericParameterType()).getDeclaredFields()) {
            field.setAccessible(true);
            field.set(?, anEntity);
        }

        return true;
    }

How can i set a entity field in Interceptor?





Aucun commentaire:

Enregistrer un commentaire