【问题标题】:Spring MVC. No mapping found for HTTP request with URI春天MVC。找不到带有 URI 的 HTTP 请求的映射
【发布时间】:2014-12-28 05:38:24
【问题描述】:

我的观点有什么问题?

@EnableWebMvc
@Configuration
class WebMvcConfig extends WebMvcConfigurerAdapter {
    @Bean
    public ViewResolver getViewResolver(){
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("/WEB-INF/view/");
        resolver.setSuffix(".jsp");
        return resolver;
    }
}


@Configuration
@ComponentScan(basePackages = "com.wordparty")
class AppConfig {
}

@Controller
class IndexController {

   @RequestMapping(value = "/", method = RequestMethod.GET)
   public String showIndex() {
       return "index";
   }

}

这是我的包结构

main
--java
----com.wordparty
      ...
--webapp
----WEB-INF
------view
--------index.jsp

我收到 404 响应。在控制台中,我看到找不到我的页面的消息。如果我写@ResponseBody,那么它会毫无问题地从控制器返回文本...... 哪里出错了?

附:我正在使用 Spring 4 + Java 8

【问题讨论】:

  • 你输入了什么网址?
  • 我的根应用程序
  • 请完整输入。 URL 或部署不正确。
  • 您的 web.xml 是否有一个包含 index.jsp 的 条目?

标签: java spring-mvc


【解决方案1】:

我解决了这个问题.. 我的调度程序 servlet 有 /* 映射而不是 /

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-16
    • 1970-01-01
    • 2016-02-05
    • 2017-04-24
    • 2012-04-16
    • 1970-01-01
    相关资源
    最近更新 更多