RT,代码如下:
applicationContext.xml
org.hibernate.cache.ehcache.EhCacheRegionFactory
true
true
org.hibernate.dialect.MySQL5InnoDBDialect
true
true
update
spring-mvc.xml
web.xml
ssshp
contextConfigLocation
classpath*:applicationContext.xml
org.springframework.web.context.ContextLoaderListener
dispatcher
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring-mvc.xml
1
dispatcher
/
index.html
TestController.java
@RestController
public class TestController {
@RequestMapping("/test/{test}")
public String test(@PathVariable String test) {
return test;
}
}
请求地址为:
http://localhost:8081/ssshp/test/jkljkle...
返回结果:
HTTP ERROR 404
Problem accessing /ssshp/test/jkljklew. Reason:
Not Found Powered by Jetty:// 9.3.8.v20160314
但是请求地址改成
http://localhost:8081/ssshp/index.html
可以正常显示。。。
这个问题网上搜了两天,没发现哪里错了,心累,各位大大求解QAQ
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
因为jkljklew.html页面不存在啊。
这里加个日志就明白了
可否把你的项目目录结构贴出来瞧瞧?
照你这个错误情况,感觉是 index.html 是在发布目录的根目录下的,没有走 DispatcherServlet,所以可以访问, 上面一个报错你看是不是 因为 no handler,应该是Controller没有被扫描到吧。
我尝试了下,自己也走了个大坑,终于出来了。
如果你的错不是这个的话,把项目拿出来看看吧,就这点信息看解决不了错误
对了,还有个好东西: BeanPostProcessor
你百度下就知道了。 可以用来检测你的bean是否被spring IoC容器加载了