Seam 2.2.0 URL rewrite not working

﹥>﹥吖頭↗ 提交于 2019-12-23 19:15:56

问题


I'm trying a simple example of URL rewriting, but it's not working for me. I'm using Seam 2.2.0 deployed to JBoss 5.1.0.

My pages.xml contains:

 <page view-id="/html/index.xhtml">
    <rewrite pattern="/home" />
</page>

and

<page view-id="/html/common/redirect.xhtml" action="#{redirectAction.redirect}">
    <rewrite pattern="/link" />
    ...

My components.xml contains:

    <web:rewrite-filter view-mapping="*.seam"/>

As far as I can tell from the documentation, that should be all I need. However, none of the internal links appear different, and if enter the URL: http://mysite/home or mysite/link?param=something, I just get a 404 page. What am I missing?


回答1:


I had the same problem when I tried to move from the Tuckey Rewrite Filter to Seam. After some trial and error I finally noticed that I had a page.xml for the view I but added the pattern in the main pages.xml. The former seems to overwrite the latter.




回答2:


From the seam documentation:

"The view-mapping parameter must match the Servlet mapping defined for the Faces Servlet in the web.xml file. If omitted, the rewrite filter assumes the pattern *.seam."




回答3:


I don't know why you approach is not working. But don't forget that you can use viewName.page.xml file for the same purpose.
For an example since the name of your page is index.xhtml you have to create the index.page.xml file inside the same folder which contains the index.xhtml file(in your case inside the html folder).

In index.page.xml file add this.

<rewrite pattern="/home" />

As you are already doing your component.xml file should contain the line

<web:rewrite-filter view-mapping="*.seam"/>

Deploy again and it should work.



来源:https://stackoverflow.com/questions/1440641/seam-2-2-0-url-rewrite-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!