Google app engine - Servlet Mapping for Google App Engine and Spring/404 no mapping found
2013-09-25 10:34
281 查看
This post is all about Spring MVC 3 and Google App Engine and their interaction.
The starting point for this project was the
Google App Engine’s documentation, the
Google Eclipse plugin, and some tutorials found on various sites.
After reading all about the App Engine and Spring, the first thing to do was to create a project in our favorite editor, Eclipse. This generated some necessary files, and gave us a good starting point. As we want to use Spring to perform all its magic, we’ve
created a web.xml like this:
This configuration would redirect all incoming requests to our Spring Dispatcher Servlet that will handle everything from there on. At leaset that’s what we’ve thought. After firing up the local App Engine development server, an error appeared for every
request issued from the browser (lets say http://localhost:8888/index). We have set up mapping for that particular url in our Spring controller, but we still got the same error:
After some googling around, we have realized that there is no need for the wildcard in the url-pattern, but if we simply put “/” there, everything will work nicely.
My curiosity didn’t let me rest on this, so I have investigated a bit more. I wanted for every not specified url to fall back on the index page. Lets try adding the wildcard back to the web.xml, and also to include it in the Spring controller:
And again an error:
Okay, expectedly this didn’t go well, so the third combination was the winning one: no wildcard in web.xml, and with wildcard in the Spring controller. And here are the two final codes:
Web.xml
Spring controller
This have solved the issue that we were having with the App Engine not wanting to forward to the Spring controller.
总结: Google app engine 的bug, 所以在配置app engine + spring MVC 项目时,请求资源找不到 可以尝试通配符配置。
搞了好多天,终于在http://alasdoo.com/2010/07/servlet-mapping-for-google-app-engine-and-spring/ 找到了答案。
The starting point for this project was the
Google App Engine’s documentation, the
Google Eclipse plugin, and some tutorials found on various sites.
After reading all about the App Engine and Spring, the first thing to do was to create a project in our favorite editor, Eclipse. This generated some necessary files, and gave us a good starting point. As we want to use Spring to perform all its magic, we’ve
created a web.xml like this:
01 | < servlet > |
02 | < servlet-name >dispatcher</ servlet-name > |
03 | < servlet-class >org.springframework.web.servlet.DispatcherServlet</ servlet-class > |
04 | < load-on-startup >1</ load-on-startup > |
05 | </ servlet > |
06 |
07 | < servlet-mapping > |
08 | < servlet-name >dispatcher</ servlet-name > |
09 | < url-pattern >/*</ url-pattern > |
10 | </ servlet-mapping > |
request issued from the browser (lets say http://localhost:8888/index). We have set up mapping for that particular url in our Spring controller, but we still got the same error:
1 | Jul 21, 2010 8:02:33 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound |
2 | WARNING: No mapping found for HTTP request with URI [/WEB-INF/views/index.jsp] in DispatcherServlet with name 'dispatcher' |
My curiosity didn’t let me rest on this, so I have investigated a bit more. I wanted for every not specified url to fall back on the index page. Lets try adding the wildcard back to the web.xml, and also to include it in the Spring controller:
1 | @RequestMapping ( "/*" ) |
2 | public String home (Model model) { |
3 | return index(model); |
4 | } |
1 | Jul 21, 2010 8:04:32 AM org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleNoSuchRequestHandlingMethod |
2 | WARNING: No matching handler method found for servlet request: path '/WEB-INF/views/index.jsp', method 'GET', parameters map[[empty]] |
Web.xml
01 | < servlet > |
02 | < servlet-name >dispatcher</ servlet-name > |
03 | < servlet-class >org.springframework.web.servlet.DispatcherServlet</ servlet-class > |
04 | < load-on-startup >1</ load-on-startup > |
05 | </ servlet > |
06 |
07 | < servlet-mapping > |
08 | < servlet-name >dispatcher</ servlet-name > |
09 | < url-pattern >/</ url-pattern > |
10 | </ servlet-mapping > |
1 | @RequestMapping ( "/*" ) |
2 | public String home (Model model) { |
3 | return index(model); |
4 | } |
总结: Google app engine 的bug, 所以在配置app engine + spring MVC 项目时,请求资源找不到 可以尝试通配符配置。
搞了好多天,终于在http://alasdoo.com/2010/07/servlet-mapping-for-google-app-engine-and-spring/ 找到了答案。
相关文章推荐
- Spring : No mapping found for HTTP request with URI in DispatcherServlet with name "..."
- spring管理事务失效的原因和No mapping found for HTTP request with URI []DispatcherServlet with name 'sprinmvc错误
- spring框架的项目报错:No mapping found for HTTP request with URI [ ] in DispatcherServlet with name 'spring'
- No mapping found for HTTP request with URI [/login.do] in DispatcherServlet with name 'spring'
- No mapping found for HTTP request with URI [/springmvc/queryitems.action] in DispatcherServlet with
- 警告: No mapping found for HTTP request with URI [/springmv/iew] in DispatcherServlet with name 'sprin
- org.springframework.web.se rvlet.DispatcherServlet.noHandlerFound No mapping found for HTTP request
- [org.springframework.web.servlet.PageNotFound] - No mapping found for HTTP request with URI
- [org.springframework.web.servlet.PageNotFound] - No mapping found for HTTP request with URI [/ssm/us
- org.springframework.web.servlet.PageNotFound noHandlerFound 警告: No mapping found for HTTP request w
- No mapping found for HTTP request with URI [/prjName/contro] in DispatcherServlet with name 'spring'
- No mapping found for HTTP request with URI [/SpringMVC/hello] in DispatcherServlet with name 'chapte
- spring mvc No mapping found for HTTP request with URI [] in DispatcherServlet
- WARNING: No mapping found for HTTP request with URI [/app/add] in DispatcherServlet with name '...'
- No mapping found for HTTP request with URI [/spring/WEB-INF/page/index.jsp] in DispatcherServlet with name &#39;spring&#39;
- org.springframework.web.servlet.DispatcherServlet noHandlerFound 警告: No mapping found for HTTP reque
- org.springframework.web.servlet.PageNotFound]-[WARN] No mapping found for HTTP request with URI [/re
- 警告: No mapping found for HTTP request with URI [/Springmvc/test] in DispatcherServlet with dispatche
- spring3+struts2+hibernate3整合出现的问题,No mapping found for dependency [type=java.lang.String, name='str
- No mapping found for HTTP request with URI [/bdp/] in DispatcherServlet with name