我真的是前端开发的新手。我创建了一个maven项目,并使用Spring Boot框架完成了我的REST API入口点的定义。我想使用reactJS将一个基本的前端添加到项目中。因此,我从基本的html欢迎开始。我添加了war / WEB-inf / index.jsp欢迎页面:
<html>
<head><title>Example</title></head>
<body>
<h1>Example</h1>
<p>This is my test.</p>
</body>
</html>
还有一个war / WEB-inf / web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
</web-app>
尝试通过转到localhost:8080访问页面
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Jun 21 12:33:05 CEST 2016
There was an unexpected error (type=Not Found, status=404).
No message available
我将不胜感激
如果您只想提供静态内容,并且正在使用Spring boot,则只需index.html
在src/main/resources/public
orsrc/main/resources/static
目录中创建一个文件。如果您只打算使用React(或任何其他JavaScript框架),则此设置应该有效。只需在此文件夹中添加所有JavaScript / CSS / HTML。
如果需要动态HTML页面(例如,使用JSP / JSTL),则可以将其添加到src/main/resources/templates
文件夹中,但是您可能必须定义一个控制器才能使用index.jsp
模板文件。
您也不需要Web描述符(web.xml),因此可以将其删除。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句