使用spring从jar文件访问静态html页面

时间:2015-05-26 07:35:03

标签: java spring spring-mvc jar

我想使用spring调用/ WEB-INF / lib下jar中的home.html文件。

以下是配置类

@Configuration
@ComponentScan("com.barclays.mobile.gateway.controller")
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter{

@Bean(name = "viewResolver")
public InternalResourceViewResolver getViewResolver() {
    InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
    viewResolver.setPrefix("/WEB-INF/");
    viewResolver.setSuffix(".html");
    return viewResolver;
}

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry.addResourceHandler("/component/**").addResourceLocations("classpath:/app/component/*");
   registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/app/assets/*");
   registry.addResourceHandler("/home/**").addResourceLocations("classpath:/app/*");
}

}

以下是控制器:

@Controller
public class StaffController {

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

请建议如何操作。?

1 个答案:

答案 0 :(得分:0)

/home删除<a href="http://myserver.com/sendmail?to=me@home.com&from=you@home.com&subject=hello&body=something> Send an email </a> ,我想这就是问题