浏览 2621 次
该帖已经被评为隐藏帖
|
|
---|---|
作者 | 正文 |
发表时间:2009-10-22
<!-- Servlets --> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/guestbook/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/note/*</url-pattern> </servlet-mapping> 在controller里面分别有对应的controller @Controller @RequestMapping(value = "/note") public class Note { @RequestMapping(value = "/show", method = RequestMethod.GET) public String show(Model model) { return "note/show"; } ... } @Controller @RequestMapping(value = "/guestbook") public class Note { @RequestMapping(value = "/show", method = RequestMethod.GET) public String show(Model model) { return "guestbook/show"; } ... } 当有多个前缀映射的时候,springmvc就不认得了? 看起来像前缀映射时springmvc取得的参数是url-pattern里面的*的部分。 盼高手解决,谢谢 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2009-10-22
最后修改:2009-10-22
还是自己解决了...
<servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> 干脆全部都映射到dispatcher-servlet好了,最多写多个controller映射"/"根地址index @Controller public class IndexRedirect { @RequestMapping(value = "/", method = RequestMethod.GET) public String index() { return "index"; } | 变相解决了-,- |
|
返回顶楼 | |
发表时间:2009-12-23
<!-- Servlets -->
<servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/guestbook/*.do</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/note/*.html</url-pattern> </servlet-mapping> 在controller里面分别有对应的controller Java代码 @Controller public class Note { @RequestMapping("/note.do") public String show(Model model) { return "note/show"; } ... } Java代码 @Controller public class Note { @RequestMapping("/guestbook.html") public String show(Model model) { return "guestbook/show"; } ... } |
|
返回顶楼 | |