in many j2ee applications, especially which developed by light-weight framework,such as struts, we can easily see the url pattern as follows :
In contrast, the url pattern used by ruby on rails applications are totally different:
Compare the two url patterns, I think most people may choose the latter, for its simplicity and beauty. Apparently, the second one reduce the usage of symbol ? and &. beside that , the second one also is 'search engine friendly' -- it has a higher chance to be searched by searching engine like google. So , hao can we get way from the ugly url pattern in j2ee applications. the answer is : url-rewrite.
url-rewrite is a technology that substitute dynamic pages for static pages. for example, the page /user/list.do?id=123 can be visited by url /url/list/123 if we have configured related url-rewrite rule.
there are two ways to implement url-rewrite in j2ee application:
in this topic, i will introduce the second way.(the other would be introduced serval days latter.)
the stepes to use UrlRewriteFilter in ur app as follows:
urlrewrite.xml introduction
urlrewrite.xml must have a root element called <urlrewrite></urlrewrite> , and at least contains one "rule" element.
'rule' element is the core of xml. a 'rule' element stand for a url-rewrite rule. 'rule' element must contains a 'to' and 'from' element, and for some advanced application, also could contains the optional elements like 'condition' and 'set'. the official site describe the process flow as follows:
the value specified in 'to' and 'from' elements must be relative to the request context, and can be a regular expression in the perl5 style.