【发布时间】:2018-01-20 22:12:03
【问题描述】:
我有一个在 Spring Boot 应用程序中提供服务的页面,但它通过 Thymeleaf 呈现视图。我最初用 HTML 编写它并将其连接到外部 javascript 文件,以允许将数据提交到数据库的功能。我无法让它工作,我在 Thymeleaf 做。但是,我一直收到 404。
这是我正在使用的文档:
http://www.thymeleaf.org/doc/articles/thymeleaf3migration.html
这是我在实际页面中的代码:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" th:src="@{/js/main.js}"></script>
<title>Stereoscopics</title>
</head>
这是我得到的错误:
请求网址:http://localhost:8080/js/main.js 请求方法:GET 状态码:404 未找到 远程地址:[::1]:8080 推荐人政策:降级时不推荐人
这是我尝试过的方法
- 最初我用 HTML 构建了这个页面。只是为了记录它曾经可以工作,但我开始使用 Thymeleaf,现在可以了。它曾经看起来像这样:
<script type="text/javascript" src="js/main.js"></script>
-
我检查了我的目录结构。 javascript文件保存在:
C:...\src\main\resources\static\js
我查阅了文档。
我做错了什么?该页面需要与javascript连接,以便用户可以向数据库提交数据。
【问题讨论】:
标签: javascript thymeleaf