No mapping found for HTTP request with URI

本文介绍了解决使用嵌入式Tomcat部署Maven工程的MVC项目时遇到的“NomappingfoundforHTTPrequestwithURI”错误的方法。通过调整使用tomcat7:run-war而非tomcat7:run来解决问题,并解释了配置文件中视图解析器的设置。

问题描述:使用嵌入式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.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值