Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaSpringMVC配置_Java_Spring_Spring Mvc - Fatal编程技术网

JavaSpringMVC配置

JavaSpringMVC配置,java,spring,spring-mvc,Java,Spring,Spring Mvc,我在Spring4.3.1.RELEASE中使用Java8 我有以下文件夹结构 这允许我访问webapp文件夹中的html文件 e、 g.http://localhost:8080/jbosswildfly-1.0/home.html 问题 如何配置它,以便也可以访问webapp/www文件夹中的html文件 e、 g.http://localhost:8080/jbosswildfly-1.0/www/index.html 返回: 找不到URI为的HTTP请求的映射 [/jbosswildf

我在Spring4.3.1.RELEASE中使用Java8

我有以下文件夹结构

这允许我访问
webapp
文件夹中的
html
文件

e、 g.
http://localhost:8080/jbosswildfly-1.0/home.html

问题

如何配置它,以便也可以访问
webapp/www
文件夹中的html文件

e、 g.
http://localhost:8080/jbosswildfly-1.0/www/index.html

返回:

找不到URI为的HTTP请求的映射 [/jbosswildfly-1.0/www/index.html]在DispatcherServlet中,名称为 “休息”


您可以使用
InternalResourceViewResolver
设置路径的前缀和后缀部分。比如说,

@Bean
public InternalResourceViewResolver getInternalResourceViewresolver(){
    InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
    viewResolver.setPrefix("/www/");
    viewResolver.setSuffix(".html");
    viewResolver.setOrder(0);
    return viewResolver;
}

看,谢谢可怕的袋熊,我尝试了以下方法,但没有成功<代码>注册表.addResourceHandler(“/webapp/**”).addResourceLocations(“/webapp/”)如果删除注册表.addResourceHandler(“*.html”).addResourceLocations(“/”),会发生什么规则。似乎是万能的,我确实删除了万能的
(“/”
规则。我就用上面的那个试过了。谢谢吓人的袋熊,你给我指明了正确的方向。以下工作正常:
registry.addResourceHandler(“/**”).addResourceLocations(“/”)
谢谢Zionz,我是否将此方法添加到现有的
MvcConfig
类中?我需要扩展另一个类吗?同一个类本身。
没有找到URI为[/jbosswildfly-1.0/home.html]和
[/jbosswildfly-1.0/www/index.html]的HTTP请求的映射。谢谢你的建议,但我刚刚找到了一个解决方案。如果我添加以下内容:
registry.addResourceHandler(“/**”).addResourceLocations(“/”)‌​;
@Bean
public InternalResourceViewResolver getInternalResourceViewresolver(){
    InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
    viewResolver.setPrefix("/www/");
    viewResolver.setSuffix(".html");
    viewResolver.setOrder(0);
    return viewResolver;
}