Spring mvc 当Tapestry映射到上时,如何将DispatcherServlet映射到/foo/*上/*
我试图让Tapestry和DispatcherServlet在我的应用程序中共存,但这让我抓狂。我知道我必须在web.xml中定义Servlet,给它分配一个URL,因为Tapestry被分配给Spring mvc 当Tapestry映射到上时,如何将DispatcherServlet映射到/foo/*上/*,spring-mvc,servlets,tapestry,Spring Mvc,Servlets,Tapestry,我试图让Tapestry和DispatcherServlet在我的应用程序中共存,但这让我抓狂。我知道我必须在web.xml中定义Servlet,给它分配一个URL,因为Tapestry被分配给/*,所以我必须在Tapestry AppModule中排除Servlet URL public static void contributeIgnoredPathsFilter( final Configuration<String> configuration) {
/*
,所以我必须在Tapestry AppModule中排除Servlet URL
public static void contributeIgnoredPathsFilter(
final Configuration<String> configuration) {
configuration.add("/bots/.*");
}
我做错了什么?
提前感谢servlet映射中的URL模式提供了部分URL,因此相对而言,控制器中的URL不必包括映射中指定的URL部分 只有更改控制器代码,当访问
/bots/
@RequestMapping(value = "/", method = RequestMethod.GET, headers = "Accept=*")
正如chrylis所说,对于旧代码,url应该是
/bots/bots/
,首先,更具体地说,您认为您为映射尝试过的一切,以及您尝试过的整个GET
请求的转储(例如,显示的代码应该是/bots/bots/
)。您是否尝试过删除方法
和标题
的狭窄说明符?您是否在日志中确认了控制器实际上正在加载?真不好意思,我不明白url映射是如何工作的,简单明了,我尝试了一些关于通配符和绝对路由的方法,但从未想过servlet定义中指定的url将提供映射路由的一部分,我只是觉得我的行为就像一个正则表达式来匹配。
@RequestMapping(value = "/", method = RequestMethod.GET, headers = "Accept=*")
@Controller
public class WelcomeController {
@ResponseBody
@RequestMapping(value = "/bots/", method = RequestMethod.GET, headers = "Accept=*")
public String plaintext(HttpServletResponse response) {
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
return "HELLO";
}
}
@RequestMapping(value = "/", method = RequestMethod.GET, headers = "Accept=*")