简体   繁体   English

学习如何使用漂亮的脸蛋

[英]learning how to use pretty-faces

I'm starting with PrettyFaces and i would like a url like this: 我从PrettyFaces开始,我想要一个这样的网址:

"/project/car/alter/120" -- this is pretty link.

But when i send a GET request in JSF i got this: 但是当我在JSF中发送GET请求时,我得到了:

"/project/car?action=alter&id=120" 

If i make this in pretty-config.xml: 如果我在pretty-config.xml中进行此操作:

<url-mapping>
        <pattern value="/car/#{action}/#{id}" />
        <view-id value="/car?action=alter&id=120" />
    </url-mapping>

This don't work because i can't generate the "pattern" link. 这不起作用,因为我无法生成“模式”链接。 How can i solve this ? 我该如何解决?

First, you should not hard-code your parameter values in the url-mapping configuration. 首先,您不应该在url映射配置中对参数值进行硬编码。 It should look like this: 它看起来应该像这样:

<url-mapping>
    <pattern value="/car/#{action}/#{id}" />
    <view-id value="/car.xhtml" />
</url-mapping>

Next, you should use to generate your URLs in your XHTML pages: 接下来,您应该用来在XHTML页面中生成URL:

http://www.ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/outbound_rewriting.html#jsf http://www.ocpsoft.org/docs/prettyfaces/3.3.3/zh-CN/html/outbound_rewriting.html#jsf

<h:link outcome="/car" value="View car>
    <f:param name="action" value="view" />
    <f:param name="id" value="231" />
</h:link>

Does this answer your question? 这回答了你的问题了吗?

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

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