我是J2EE / Spring的新手。
我正在开发一个RESTful Spring服务。控制器类有几个映射。我的应用程序中没有web.xml文件。
现在,我想在war文件中显示index.xml文件,该文件是从构建生成的。有没有办法可以输入网址http://localhost/healthcheck/version
,它会显示这个静态index.html文件。
编辑:我尝试使用
@Controller
@RequestMapping("/healthcheck")
public class HealthCheck {
@RequestMapping(value = "/version", method = RequestMethod.GET)
public String getVersion() throws Exception {
URL indexUrl = servletContext.getResource("/index.html");
System.out.println("url path : " + indexUrl.getPath());
return indexUrl.getPath();
}
}
但是,当我输入http://localhost/healthcheck/version
时,我在日志中收到以下DEBUG消息,
10:23:47.199 [http-bio-8080-exec-2] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /localhost/wcm-service/index.html
10:23:47.200 [http-bio-8080-exec-2] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/localhost/wcm-service/index.html]
10:23:47.200 [http-bio-8080-exec-2] WARN o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/wcm-service/localhost/wcm-service/index.html] in DispatcherServlet with name 'wcm-service'
任何帮助都将受到高度赞赏。
由于