【发布时间】:2016-09-25 07:02:08
【问题描述】:
出于安全原因,我已经集成了我的 Spring MVC 应用程序 Shiro。
我所有的网址都可以正常工作,但我有一些可以直接访问的 html 页面。
我如何保护这些页面,这意味着如果用户没有登录到应用程序并尝试打开 html 页面,他们应该被重定向到登录页面。
我在jetty和tomcat服务器上测试过。
码头
http://ip:port - works fine, redirects to login page
http://ip:port/html/ - opens html pages
雄猫
http://localhost:8070/my-app/html/myPage.html - opens html pages
基本上我不想在没有用户登录的情况下直接访问我的静态内容。
我的 html 文件与 Angular 代码集成在一起。是否有任何类型的 servlet 可以从中创建和返回 html。这意味着我将从其他特定位置读取 html,解析并返回 html 作为响应。
html 文件位置 - my-app\html\myPage.html
web.xml中的Shiro设置
filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
当我构建战争时,它也会复制 web-inf 之外的图像、html 文件夹。 如何避免使用maven在web-inf之外复制图片、html文件夹
【问题讨论】:
标签: java html spring servlets shiro