No mapping found for HTTP request with URI

問題描述:使用嵌入式tomcat跑maven工程的mvc,一直報“No mapping found for HTTP request with URI”

解決方法:使用tomcat7:run-war  運行工程。 而不是tomcat7:run

原因解析

@Configuration
@EnableWebMvc
@ComponentScan("com.wisely.highlight_springmvc4")
public class MyMvcConfig {
    @Bean
    public InternalResourceViewResolver viewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setPrefix("/WEB-INF/classes/views/");
        viewResolver.setSuffix(".jsp");
       /*  viewResolver.setSuffix(".html");*/
        viewResolver.setViewClass(JstlView.class);
        return viewResolver;
    }
}

https://tomcat.apache.org/maven-plugin-2.0-beta-1/tomcat7-maven-plugin/run-mojo.html

tomcat7:run

Full name:

org.apache.tomcat.maven:tomcat7-maven-plugin:2.0-beta-1:run

Description:

Runs the current project as a dynamic web application using anembedded Tomcat server.

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: runtime.
  • Since version: 2.0.
  • Invokes the execution of the lifecycle phase compile prior to executing itself.

https://tomcat.apache.org/maven-plugin-2.0-beta-1/tomcat7-maven-plugin/run-war-mojo.html

tomcat7:run-war

Full name:

org.apache.tomcat.maven:tomcat7-maven-plugin:2.0-beta-1:run-war

Description:

Runs the current project as a packaged web application using anembedded Tomcat server.

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: runtime.
  • Since version: 2.0.
  • Invokes the execution of the lifecycle phase package prior to executing itself.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章