Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/400.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
Java 在Spring Boot中名为“DispatcherServlet”的DispatcherServlet中找不到URI为[/css/school\u style.css]的HTTP请求的映射_Java_Spring_Spring Mvc_Spring Boot - Fatal编程技术网

Java 在Spring Boot中名为“DispatcherServlet”的DispatcherServlet中找不到URI为[/css/school\u style.css]的HTTP请求的映射

Java 在Spring Boot中名为“DispatcherServlet”的DispatcherServlet中找不到URI为[/css/school\u style.css]的HTTP请求的映射,java,spring,spring-mvc,spring-boot,Java,Spring,Spring Mvc,Spring Boot,这里我使用SpringBoot、hibernate和SQLServer数据库。 问题是,.css没有加载。 如果我没有与hibernate集成,那么.css的加载是完美的。 我不明白为什么当我与hibernate集成时,css没有加载? 请给出解决方案 pom.xml 4.0.0 <groupId>com.example</groupId> <artifactId>AngularIntegration</artifactId> <versio

这里我使用SpringBoot、hibernate和SQLServer数据库。 问题是,.css没有加载。 如果我没有与hibernate集成,那么.css的加载是完美的。 我不明白为什么当我与hibernate集成时,css没有加载? 请给出解决方案

pom.xml 4.0.0

<groupId>com.example</groupId>
<artifactId>AngularIntegration</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>AngularIntegration</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.4.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- Optional, for bootstrap -->
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootstrap</artifactId>
        <version>3.3.7</version>
    </dependency>
    <!-- Tomcat embedded container-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>net.sourceforge.jtds</groupId>
        <artifactId>jtds</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
应用程序属性

spring.datasource.url=jdbc:jtds:sqlserver://SQLSERVER/abc
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-net.sourceforge.jtds.jdbc.Driver
欢迎光临

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>AngularJS Example</title>  

<link rel="stylesheet" href="/css/school_style.css" type="text/css"/>

</head>
<body>
<div id="main_container">
    <div id="content_container">
        <div id="content">
            <div id="contentborder">
                <div class="content_head">Class Students</div>
                <form method="post" name="frm" id="frm"> 


                    <table align="center" cellpadding="2" cellspacing="2" class="table_border" width="90%">
                        <tr>
                            <br></br>
                            <td class="td_line" align="right" width="50%"><b>Class : </b></td>
                            <td class="td_line" align="left" width="50%">
                            <select size="1" name="cl" id="cl" class="validate[required]">
                                <option value="">Select</option>

                                    <option th:each="clazz : ${allClasses}" value="${clazz.classID}">
                                    <span th:text="${clazz.className}"></span>
                                    </option>

                            </select>
                            </td>
                        </tr>

                        <tr>
                            <td class="td_line" align="right" width="50%"><b>Section :</b></td>
                            <td class="td_line" align="left" width="50%">
                            <select size="1" name="section" id="section" class="validate[required]">
                                    <option value="">Select</option>
                            </select>
                            </td>
                        </tr>

                        <tr>
                            <td class="td_line" align="right" width="50%"><b>Students :</b></td>
                            <td class="td_line" align="left" width="50%">
                            <select size="1" name="term" id="term" onClick="return valid()" class="validate[required]">
                                    <option value="">Select</option>
                            </select>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center"><br></br>
                                <input type="submit" class="submit" value="Submit"/>
                                <input type="reset" class="submit" value="Reset"/>
                            </td>
                        </tr>
                    </table>

                </form>
            </div>
        </div>
    </div>
</div>

</body>
</html>
删除@EnableWebMvc,您还可以从DBConfiguration`中删除@COmponentScan并重新启动应用程序。首先删除/here href=/css/school_style.css。应该是href=css/school\u style.cssTry此答案:
spring.datasource.url=jdbc:jtds:sqlserver://SQLSERVER/abc
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-net.sourceforge.jtds.jdbc.Driver
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>AngularJS Example</title>  

<link rel="stylesheet" href="/css/school_style.css" type="text/css"/>

</head>
<body>
<div id="main_container">
    <div id="content_container">
        <div id="content">
            <div id="contentborder">
                <div class="content_head">Class Students</div>
                <form method="post" name="frm" id="frm"> 


                    <table align="center" cellpadding="2" cellspacing="2" class="table_border" width="90%">
                        <tr>
                            <br></br>
                            <td class="td_line" align="right" width="50%"><b>Class : </b></td>
                            <td class="td_line" align="left" width="50%">
                            <select size="1" name="cl" id="cl" class="validate[required]">
                                <option value="">Select</option>

                                    <option th:each="clazz : ${allClasses}" value="${clazz.classID}">
                                    <span th:text="${clazz.className}"></span>
                                    </option>

                            </select>
                            </td>
                        </tr>

                        <tr>
                            <td class="td_line" align="right" width="50%"><b>Section :</b></td>
                            <td class="td_line" align="left" width="50%">
                            <select size="1" name="section" id="section" class="validate[required]">
                                    <option value="">Select</option>
                            </select>
                            </td>
                        </tr>

                        <tr>
                            <td class="td_line" align="right" width="50%"><b>Students :</b></td>
                            <td class="td_line" align="left" width="50%">
                            <select size="1" name="term" id="term" onClick="return valid()" class="validate[required]">
                                    <option value="">Select</option>
                            </select>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center"><br></br>
                                <input type="submit" class="submit" value="Submit"/>
                                <input type="reset" class="submit" value="Reset"/>
                            </td>
                        </tr>
                    </table>

                </form>
            </div>
        </div>
    </div>
</div>

</body>
</html>