由于某些原因,我的团队在Java配置上使用spring XML配置。当我实现new时CorsFilter,我用谷歌搜索并找到了示例Java Config,如下所示:@Componentpublic class CorsFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { response.addHeader("Access-Control-Allow-Origin", "*"); response .addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, PATCH, HEAD, OPTIONS"); response.addHeader("Access-Control-Allow-Headers", "Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers"); response.addHeader("Access-Control-Expose-Headers", "Access-Control-Allow-Origin, Access-Control-Allow-Credentials"); response.addHeader("Access-Control-Allow-Credentials", "true"); response.addIntHeader("Access-Control-Max-Age", 10); filterChain.doFilter(request, response); }}但是如何转换为等效的Spring XML配置呢?我知道我们可以创建一个名为的beancorsFilter并设置一些属性值。但是,如何在XML配置中覆盖父方法并执行具有副作用的操作呢?(如在上面添加标题)
添加回答
举报
0/150
提交
取消