No mapping found for HTTP request with URI [/myappname/] in DispatcherServlet with name 'appServlet'

六眼飞鱼酱① 提交于 2019-12-01 13:38:46
shazinltc

I think your are missing <mvc:annotation-driven/> which is required to read the @Controller and @RequestMapping annotations. You can read more on this here and here.

The solutio is to keep in DispatcherServlet Context file both annotation-driven tags like here:

<annotation-driven />
<tx:annotation-driven />

I haven't found similar solution so I am gooing to leave it here.

Have this in your spring servlet.xml file

xmlns:mvc="http://www.springframework.org/schema/mvc
xmlns:tx="http://www.springframework.org/schema/tx"

and

http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd

and

<mvc:annotation-driven />
<tx:annotation-driven /> 

In your controller class, use

 @Controller
 public class IndexController {..}

and it works!

UtResolver

I was facing the same exception and was trying all above solutions but nothing helped but I did get a pointer the issue was because the class was not generated in the target class folder and it was due to incorrect Maven Project Structure which was leading to no compilation of Java controller class.

Check if you have below structure and then if class is generated in target->class folder then only try above suggestions.

Project
  src
    main
      java
      resources
    test
      java
      resources

Make sure that your .java file is under src/main/java instead src/main/resources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!