简体   繁体   English

漂亮的面孔不起作用

[英]pretty faces does not work

I tried pretty faces with my jsf app.URL has not changed.I followed the steps mentioned on the site. 我用我的jsf app.URL尝试了漂亮的脸。我没有改变。我按照网站上提到的步骤。
pom.xml 的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>

I added pretty-config.xml in WEB-INF/ 我在WEB-INF /中添加了pretty-config.xml
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>

my local project url(full url) 我的本地项目网址(完整网址)

http://localhost:9080/projectName/pages/unsecure/login.jsf HTTP://本地主机:9080 /项目名称/页/不安全/ login.jsf

I use myfaces2.2.7,spring/security,hibernate,tomcat7 我使用myfaces2.2.7,spring / security,hibernate,tomcat7
Is there another setting I need to do?What I'm missing.I dont understand. 我需要做另一种设置吗?我缺少什么。我不明白。
What exactly should I do?Thanks in advance.. 我该怎么办?先谢谢..

UPDATE : 更新
I don't get any error.just does not work. 我没有得到任何错误。只是不起作用。 URL does not change.. 网址不会改变..

The URL in the browser isn't going to change automatically. 浏览器中的URL不会自动更改。 PrettyFaces maps pretty URLs to internal URLs. PrettyFaces将漂亮的URL映射到内部URL。 So if you request: 所以如果你要求:

http://localhost:9080/projectName/login

You would actually see the /pages/unsecure/login.jsf page as specified in the configuration. 您实际上会看到配置中指定的/pages/unsecure/login.jsf页面。 Navigation using JSF navigation or internal redirects to this page will automatically use the pretty URL. 使用JSF导航或内部重定向到此页面的导航将自动使用漂亮的URL。

If you want to automatically redirect from the internal URL to the pretty URL from external Requests (like in your example,) then you need to add a rewrite condition to do that: 如果要自动从内部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>

Alternatively, you can use Rewrite directly for both of these rules (since you are already using Rewrite with the PrettyFaces extension), using the Join rule: 或者,您可以直接使用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());
    }
}

Note the .withInboundCorrection() method call. 注意.withInboundCorrection()方法调用。 This sets up the inbound redirect from the OLD url to the NEW url automatically. 这会自动将OLD URL的入站重定向设置为NEW url。

I hope this helps. 我希望这有帮助。 Cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM