Reputation: 396
I am really new to front end development. I created a maven project and finished defining my REST API entry points using spring boot framework. I would like to add to the project a basic front end using reactJS. So I started with the basic html welcome. I added a war/WEB-inf/index.jsp welcome page:
<html>
<head><title>Example</title></head>
<body>
<h1>Example</h1>
<p>This is my test.</p>
</body>
</html>
And a 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>
Trying to access the page by going to 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
I would appreciate some help
Upvotes: 2
Views: 1775
Reputation: 44735
If you just want to serve static content and you're using Spring boot, you can simply create an index.html
file inside the src/main/resources/public
or src/main/resources/static
directory. If you're only going to use React (or any other JavaScript framework), this setup should work. Just add all your JavaScript/CSS/HTML within this folder.
If you need a dynamic HTML page (using JSP/JSTL for example), you can add it to the src/main/resources/templates
folder, but then you'll probably have to define a controller to use the index.jsp
template file.
You don't need a Web descriptor (web.xml) either, so you can remove that.
Upvotes: 1