简体   繁体   English

缩短JBoss Seam应用程序中REST服务的路径仍然错误

[英]Shorten path of REST service in JBoss Seam application still wrong

I got a similar question as: Shorten path of REST service in JBoss Seam application But couldn't comment on the shipmaster answer because of my initial rep. 我有一个类似的问题: 缩短JBoss Seam应用程序中的REST服务的路径,但是由于我的最初代表,无法评论shipmaster的答案。 His comment Jul 19 at 18:10 misunderstood the situation: 他在7月19日18:10的评论误解了这种情况:

Faces servlet is mapped by url-pattern *.xhtml and Seam Resource Servlet is mapped to /* . Faces Servlet通过url-pattern *.xhtml映射,而Seam Resource Servlet映射到/* The /* now gets all the url patterns, even those of *.html , because it has more priority on url-pattern matching. /*现在可以获得所有url模式,甚至是*.html的url模式,因为它在url-pattern匹配方面具有更高的优先级。

What can I change on components.xml in the code (default behavior): <resteasy:application resource-path-prefix="/rest"/> and on web.xml in the code below: 我可以在代码(默认行为): <resteasy:application resource-path-prefix="/rest"/>和web.xml中的以下代码中对components.xml进行哪些更改:

<servlet-mapping> 
    <servlet-name>Seam Resource Servlet</servlet-name>
    <url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>

In a way that my RestEasy resource could be accessed by a path like /rest/<resource> instead of /seam/resource/rest/<resource> without invalidating my *.xhtml faces servlets (using his hint of change Seam Resource Servlet url-pattern to /* )? 可以通过/rest/<resource>而不是/seam/resource/rest/<resource>类的路径访问我的RestEasy资源,而不会使我的*.xhtml face servlet无效(使用他的更改提示Seam Resource Servlet url) /*

(It is basically the unsolved question of kongo09 better detailed). (这基本上是kongo09尚未解决的问题,更详细地介绍)。

You're looking for a url-rewriting solution. 您正在寻找一个URL重写解决方案。 Seam/RestEasy still gets the full URL, but the client will get a pretty short URL. Seam / RestEasy仍然获得完整的URL,但是客户端将获得非常短的URL。

If you're using AJP and Apache as a front-end, you could go with httpd's standard mod_rewrite http://httpd.apache.org/docs/2.0/misc/rewriteguide.html . 如果您使用AJP和Apache作为前端,则可以使用httpd的标准mod_rewrite http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

If you can afford JSF2, a simpler solution is PrettyFaces http://ocpsoft.com/prettyfaces/ 如果您负担得起JSF2,那么一个更简单的解决方案是PrettyFaces http://ocpsoft.com/prettyfaces/

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

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