如何限制对访问的JSF应用程序页面的访问,而无需;“脸”;在URL中
我有一个JSFWeb应用程序,它的URL类似于如何限制对访问的JSF应用程序页面的访问,而无需;“脸”;在URL中,jsf,web-applications,Jsf,Web Applications,我有一个JSFWeb应用程序,它的URL类似于 http://host/app/faces/<page>.xhtml http://host/app/faces/.xhtml app是上下文根目录,/faces/*是Servlet URL模式 其中页面可以是我的应用程序中的任何页面。现在,如果我使用这个URL访问任何页面,我在一些地方有一个访问控制器,如果没有某个后端服务的活动会话,它会重定向login.xhtml 如果我从URL中删除faces字符串 http://host/a
http://host/app/faces/<page>.xhtml
http://host/app/faces/.xhtml
app是上下文根目录,/faces/*是Servlet URL模式
其中页面可以是我的应用程序中的任何页面。现在,如果我使用这个URL访问任何页面,我在一些地方有一个访问控制器,如果没有某个后端服务的活动会话,它会重定向login.xhtml
如果我从URL中删除faces字符串
http://host/app/<page>.xhtml
http://host/app/.xhtml
然后呈现页面的一些静态内容
我的问题是如何停止呈现此静态内容。只需将url模式从
.xhtml
更改为.html
并使用安全约束。这将限制对xhtml文件的直接访问
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>facesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>facesServlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
<security-constraint>
<display-name>Restrict direct access to XHTML files</display-name>
<web-resource-collection>
<web-resource-name>XHTML Files</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
</web-app>
小脸蛋
javax.faces.webapp.FacesServlet
1.
小脸蛋
*.html
javax.faces.PROJECT_阶段
发展
javax.faces.DEFAULT_后缀
.xhtml
login.html
限制对XHTML文件的直接访问
XHTML文件
*.xhtml
如果您尝试使用Chrome浏览器,请在开发者工具中打开网络选项卡。您可以查看未找到的文件。