java 代码
- HTTP ERROR: 404
- Not Found
- RequestURI=/mytest/services/test
- Powered by Jetty://
Ignoring URLs
Sometimes you may want to resolve URLs to servlets other than Grails. In this case, note that Grails ignores any URLs that fail to match at least one of the patterns in the mapping. So, having:
static mappings = {
"/grails/$controller/$action?/$id?" {
...
}
}
would ensure that you could, for example, use /remoting/* for a Spring invoker servlet. Beware, though, that the pattern in the default mapping captures a large range of useful URLs.
呵呵,原来官方文档已经早有解决方案,是我太固陋寡闻,借此给碰到此类问题,又不知如何解决同类中人以一些解释不过还是有个问题,就是这样修改会影响原来正常的grail的controller/action操作,目前还不知道有何好解?
我目前所知道的方法就是将每个controller映射写死在grails-app/conf/*UrlMappings.groovy中,比较笨重,但能解决问题
--补充一个比较好的解决方案:在grails-app/conf/*UrlMappings.groovy中修改mappings,如下
java 代码
- static mappings = {
- "/$controller/$action?/$id?"{
- constraints {
- controller(matches:/.*[^(services)].*/)
- }
- }
- }