Below is the Handler interceptor, in the postHandle, i am getting modelAndView is null, by which pagination is not working.
public class JakartaHandlerInterceptorAdapter implements HandlerInterceptor {
private final CoreHandlerInterceptor interceptor;
public JakartaHandlerInterceptorAdapter(CoreHandlerInterceptor interceptor) {
this.interceptor = interceptor;
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
return interceptor.preHandle(JakartaAdapters.toCore(request), JakartaAdapters.toCore(response), handler);
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
interceptor.postHandle(JakartaAdapters.toCore(request), JakartaAdapters.toCore(response), handler, modelAndView);
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
interceptor.afterCompletion(JakartaAdapters.toCore(request), JakartaAdapters.toCore(response), handler, ex);
}
}
Below is adaptor for setting jakartaHandler into paging configuration
public class Spring6AdapterFactory {
public static HandlerInterceptor toSpring6(CoreHandlerInterceptor interceptor){
return new JakartaHandlerInterceptorAdapter(interceptor);
}
public static HandlerInterceptor toSpring6(CoreInterceptor interceptor) {
return new JakartaCoreInterceptorAdapter(interceptor);
}
}
Below is the configurations, tell me if there is wrong with the code
@Configuration
@EnableWebSecurity
public class AppConfig implements WebMvcConfigurer {
@Autowired
@Lazy @Qualifier("pagingInterceptor")
private HandlerInterceptor pagingInterceptor;
@Bean(name = "pagingInterceptor")
@Scope(SCOPE_SINGLETON)
public HandlerInterceptor pagingInterceptor(List<PagingHandler> pagingHandlers, PagingParams matrix){
return PagingInterceptor.newBuilder()
.withHandlers(pagingHandlers)
.withPagingParams(matrix)
.withPageInfoConsumer(new PagingConsumer())
.withDetagHandling()
.build(Spring6AdapterFactory::toSpring6);
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(sessionInterceptor);
registry.addInterceptor(pagingInterceptor).addPathPatterns("/**");
}
}
Below is the sample endpoint with paging annotation
@GetMapping()
@Paging
public List<File> getManagedFilesForOrganizationV3(HttpServletRequest request){
return someList;
}
I am getting null in modelAndView thats why paging is not working. Above i have added sample controller, interceptor handler, and some configuration, any leads would be great. Thanks