开发者

Spring excluding pages from urlrewrite rule set on root

Here is the simple explanation of the problem:

I have a controller RedirectCo开发者_如何学Gontroller so that I want to handle everything like http://mydomain/**

However, still I want need to redirect http://mydomain/ to index controller (or index.jspx whatever) and most probably I need to exclude /help /about URLs in the future.

The current method is I did not changed Spring Roo generated urlrewrite.xml. Here it is. Code:

<urlrewrite default-match-type="wildcard">
 <rule>
  <from>/resources/**</from>
  <to last="true">/resources/$1</to>
 </rule>
 <rule>
  <from>/static/WEB-INF/**</from>
  <set type="status">403</set>
  <to last="true">/static/WEB-INF/$1</to>
 </rule>
 <rule>
  <from>/static/**</from>
  <to last="true">/$1</to>
 </rule>
 <rule>
  <from>/</from>
  <to last="true">/app/index</to>  
 </rule>
 <rule>
  <from>/app/**</from>
  <to last="true">/app/$1</to>
 </rule>
 <rule>
  <from>/**</from>
  <to>/app/$1</to>
 </rule>
 <outbound-rule>
  <from>/app/**</from>
  <to>/$1</to>
 </outbound-rule> 
</urlrewrite>

Then I used mapping annotations in my RedirectControlller.

@RequestMapping("/**")
@Controller
public class RedirectController {
....


    @RequestMapping(method = RequestMethod.GET, value = "/{value}")
    public String get(@PathVariable String value, ModelMap modelMap, HttpServletRequest request, HttpServletResponse response) {
          ...

So that when http://mydomain/xxx is requested, this get ( ) method will use xxx value. However, when I use such a scheme, on http://mydomain/ request, index is passed as {value} (such as xxx). (which is something I do not want.)

According to mapping rules in the xml file above, any /** request is redirected to DispatcherServlet in the web.xml file so that annotation based mapping handler look at the annotation of RedirectController and simply includes all the URLs we want to exclude...

Any ideas to solve this issue?


In your urlrewrite.xml you'd have something like

<rule>
     <from>^/location/([A-Z]+)/name/([A-Z]+)</from>
     <to>/login?name=$2&location=$1</to>
</rule>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜