下面是问题的简单解释:
我有一个控制器重定向控制器,所以我想处理像
http://mydomain/
**
但是,我仍然需要重新定向
http://mydomain/
为了索引控制器(或index.jspx,无论什么),很可能我将来需要排除/help/about URL。
当前方法是我没有更改SpringRoo生成的urlrewrite.xml。在这里。
代码:
<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>
然后我在重定向控制器中使用了映射注释。
@RequestMapping("/**")
@Controller
public class RedirectController {
....
@RequestMapping(method = RequestMethod.GET, value = "/{value}")
public String get(@PathVariable String value, ModelMap modelMap, HttpServletRequest request, HttpServletResponse response) {
...
所以当
http://mydomain/xxx
请求,此get()方法将使用xxx值。但是,当我使用这样的方案时,
http://mydomain/
请求,索引作为值(如xxx)传递。(这是我不想要的。)
根据上面XML文件中的映射规则,任何/**请求都被重定向到web.xml文件中的DispatcherServlet,以便基于批注的映射处理程序查看RedirectController的批注,并且只包含我们想要排除的所有URL…
有什么办法解决这个问题吗?