96人参与 • 2026-05-15 • Java
(如果使用了拦截器)
@override
public boolean prehandle(httpservletrequest request, httpservletresponse response, object handler) throws exception {
// 如果不是映射到方法直接通过,防止静态资源被拦截
if (!(handler instanceof handlermethod)) {
return true;
}
...
}
或实现webmvcconfigure 接口中是否配置了静态资源放行
(就是使用@enablewebmvc注解的地方)
/**
* ·
* 静态资源映射
*/
@override
public void addresourcehandlers(resourcehandlerregistry registry) {
registry.addresourcehandler("/**").addresourcelocations("classpath:/meta-inf/resources/")
.addresourcelocations("classpath:/resources/").addresourcelocations("classpath:/static/")
.addresourcelocations("classpath:/public/");
super.addresourcehandlers(registry);
}
(如果仍无法访问)
<resources>
<resource>
<directory>src/main/webapp</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>如shiro或者spring security 自行配置请求过滤策略
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
您想发表意见!!点此发布评论
版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。
发表评论