[英]pretty faces does not work
我用我的jsf app.URL尝试了漂亮的脸。我没有改变。我按照网站上提到的步骤。
的pom.xml
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>2.0.12.Final</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-config-prettyfaces</artifactId>
<version>2.0.12.Final</version>
</dependency>
我在WEB-INF /中添加了pretty-config.xml
漂亮-config.xml中
<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">
<url-mapping id="login">
<pattern value="/login" />
<view-id value="/pages/unsecure/login.jsf" />
</url-mapping>
</pretty-config>
我的本地项目网址(完整网址)
我使用myfaces2.2.7,spring / security,hibernate,tomcat7
我需要做另一种设置吗?我缺少什么。我不明白。
我该怎么办?先谢谢..
更新 :
我没有得到任何错误。只是不起作用。 网址不会改变..
浏览器中的URL不会自动更改。 PrettyFaces将漂亮的URL映射到内部URL。 所以如果你要求:
http://localhost:9080/projectName/login
您实际上会看到配置中指定的/pages/unsecure/login.jsf
页面。 使用JSF导航或内部重定向到此页面的导航将自动使用漂亮的URL。
如果要自动从内部URL重定向到外部请求的漂亮URL(如示例所示),则需要添加重写条件来执行此操作:
<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">
<url-mapping id="login">
<pattern value="/login" />
<view-id value="/pages/unsecure/login.jsf" />
</url-mapping>
<rewrite match="/pages/unsecure/login.jsf" substitute="/login" redirect="301"/>
</pretty-config>
或者,您可以直接使用Rewrite来实现这两个规则(因为您已经使用了使用PrettyFaces扩展的Rewrite),使用Join
规则:
@RewriteConfiguration
public class ExampleConfigurationProvider extends HttpConfigurationProvider
{
@Override
public int priority()
{
return 10;
}
@Override
public Configuration getConfiguration(final ServletContext context)
{
return ConfigurationBuilder.begin()
.addRule(Join.path("/login").to("/pages/unsecure/login.jsf").withInboundCorrection());
}
}
注意.withInboundCorrection()
方法调用。 这会自动将OLD URL的入站重定向设置为NEW url。
我希望这有帮助。 干杯!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.