prettyfaces的 URL重写

Inbound URL Rewriting

<rewrite trailingSlash="append" toCase="lowercase" redirect="301"/>
<rewrite match="/foo" substitute="/bar" redirect="301"/>
<rewrite toCase="lowercase" redirect="chain" />
<rewrite match="/foo" trailingSlash="append" toCase="lowercase" />
<rewrite match="/foo/(/w+)/" substitute="/bar/$1/" />
<rewrite match="/foo/(/w+)/" url="http://example.com/$1/" />


    
    

The table below outlines each of the individual rewrite-rule options:

OptionAllowed valuesUsage
inboundtrue/false(Default: true) Enable or disable inbound URL rewriting for this rule. Setting this value to false means that this rule will be ignored on incoming requests.
matcha regex(Optional) Describes, via a regular expression pattern, when this 'rewrite' rule should trigger on an inbound or outbound URL. If empty, this rule will match all URLs.
outboundtrue/false(Default: true) Enable or disable outbound URL rewriting for this rule. If enabled, any matching links encoded using HttpServletResponse.encodeURL() will be rewritten according to the rules specified.
processorqualified class name(Optional.) Specify a custom processor class to perform more complex, custom URL-rewriting. This class must implement the interface: 'com.ocpsoft.pretty.faces.rewrite.Processor'
public class CustomClassProcessor implements Processor {
	public static final String RESULT = "I PROCESSED!";

	public String process(final RewriteRule rewrite, final String url) {
		return RESULT;
	}
}
redirect301, 302, chain(Default: 301) Specifies which type of redirect should be issued when this rule triggers. If 'chain' is specified, a Servlet forward will be issued to the new URL instead of a redirect.
substitutelifecycle(Optional.) The regular expression substitution value of the "match" attribute. This effectively enables a "search and replace" functionality. Regular expression back-references to the match="..." attribute are supported in the URL, so using '$' and '/' characters may change the value of the result. See Rewriting URLs that match a specific pattern, for more details.
toCaseuppercase, lowercase, ignore(Default: ignore) Change the entire URL (excluding context-path and query- parameters) to 'UPPERCASE' or 'lowercase'.
trailingSlashappend, remove, ignore(Default: ignore) Control whether trailing slashes on a URL should be appended if missing, or removed if present.
urla well-formed URL(Optional.) Specify an well-formed URL to replace the current URL. This will overwrite the context-path and query-parameters. This attribute should usually be combined with redirect="301" (default), which is recommended to prevent adverse SEO effects, loss of page- rank.) Note: You must provide a fully qualified URL, including scheme (such as 'http://", 'ftp://', 'mailto:'). Regular expression back-references to the match="..." attribute are supported in the URL, so using '$' and '/' characters may change the value of the result. See Rewriting URLs that match a specific pattern, for more details.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值