最后,我可以找出解决方案。现在urlrewrite.xml
从src / main / resources文件夹中读取。
无需在问题post(public FilterRegistrationBean tuckeyRegistrationBean()
)中声明上述bean定义,因为以下声明为的代码@Component
将自动在上下文中注册并执行url重写。
@Component
public class WsdlUrlRewriteFilter extends UrlRewriteFilter {
private static final String CONfig_LOCATION = "classpath:/urlrewrite.xml";
@Value(CONfig_LOCATION)
private Resource resource;
@Override
protected void loadUrlRewriter(FilterConfig filterConfig) throws ServletException {
try {
Conf conf = new Conf(filterConfig.getServletContext(), resource.getInputStream(), resource.getFilename(), "");
checkConf(conf);
} catch (IOException ex) {
throw new ServletException("Unable to load URL-rewrite configuration file from " + CONfig_LOCATION, ex);
}
}
}