【发布时间】: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