- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 SpringBoot MVC 模式开发一些 Web 应用程序。我有四个maven项目(DAO项目、REST项目(有用于启动应用程序的SpringBoot类)、SERVICE项目和CLIENT项目)。该项目通过依赖关系连接。
我的问题与 CLIENT 项目有关。我有 WelcomeController ,它看起来像这样:
package com.itengine.scoretracker.client.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class WelcomeController {
@RequestMapping("/")
public String welcome(){
return "static/html/index.html";
}
}
我的 html 位于此路径上:
当我将静态文件夹从 CLIENT 项目重新定位到 REST 项目中的同一位置时,我的 WelcomeController 会看到 index.html 并且一切正常。
所以请有人帮我解决这个问题,我真的需要这个 html 在 CLIENT 项目中。我没有配置 xml 的经验,因为我在 SpringBoot 类(class)中学习时没有使用这些 xml。
我的 web.xml 是空的,它们只有这个:
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "java.sun.com/dtd/web-app_2_3.dtd"; > <web-app> <display-name>Archetype Created Web Application</display-name> </web-app>
我的主类是这样的:
package com.itengine.scoretracker.rest.init;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.boot.orm.jpa.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@ComponentScan("com.itengine")
@EntityScan("com.itengine")
@EnableJpaRepositories("com.itengine.scoretracker.dao.repository")
@SpringBootApplication
public class ScoreTrackerApplication
extends SpringBootServletInitializer{
@Override
protected SpringApplicationBuilder configure(
SpringApplicationBuilder builder){
return builder.sources(ScoreTrackerApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(ScoreTrackerApplication.class, args);
}
}
提前致谢!
最佳答案
将static
文件夹移动到src/main/resources
,以便它最终部署在类路径上。然后可以删除 /
的映射。
关于java - WelcomeController 找不到index.html 的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35270562/
我正在使用 SpringBoot MVC 模式开发一些 Web 应用程序。我有四个maven项目(DAO项目、REST项目(有用于启动应用程序的SpringBoot类)、SERVICE项目和CLIEN
我希望我的欢迎 Controller 使用不同的布局: class WelcomeController 'default' else render :layout => 'wel
我是 Laravel 的新手,我不明白为什么 Controller 不工作。你能帮助我吗?谢谢。 这是 routes.php 文件: routes.php 这是 WelcomeController C
我是 Laravel 的新手,我不明白为什么 Controller 不工作。你能帮助我吗?谢谢。 这是 routes.php 文件: routes.php 这是 WelcomeController C
这是我在 Rails 服务器上运行我的第一个 ruby 应用程序时的错误。有时,我设法通过,有时我会在 60% 的时间内遇到此错误。 My Code My Error screen Abstrac
我是一名优秀的程序员,十分优秀!