beginnerCoder beginnerCoder - 2 months ago 5x
Javascript Question

Spring Rest- result page does not display results instead requested resource is not available

I don't know if I'm doing this correctly but basically I'm using spring and creating a rest client-server. The index.jsp displays a form where the user enters information about a dog, and then they click submit and it should go to the result page where it should displays the result (so what they've entered). The problem is when the user fills out the form and clicks submit I get the error that the "requested resource is not available". Can anyone tell me where I am going wrong, why does the welcome.jsp page create an error?

Index.jsp (contains the form)

<form action="welcome.jsp" th:action="@{/dog}" th:object="${dog}" method="post">
<p>Id: <input type="text" th:field="*{id}" /></p>
<p>Name: <input type="text" th:field="*{name}" /></p>
<p>heartbeat: <input type="text" th:field="*{heartbeat}" /></p>
<p>temperature: <input type="text" th:field="*{temperature}" /></p>
<p>lat: <input type="text" th:field="*{lat}" /></p>
<p>long: <input type="text" th:field="*{lon}" /></p>
<p>weight: <input type="text" th:field="*{weight}" /></p>
<p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p>


welcome.jsp (should display the result of what the user entered)

<p th:text="'id: ' + ${}" />
<p th:text="'content: ' + ${}" />
<a href="index.jsp">Submit another message</a>

DogController-get the post request

public class DogController {

private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();

@RequestMapping(value="", method = RequestMethod.GET)
public CreateDog greeting() {
return new CreateDog(counter.incrementAndGet(),"dog", 40, 25, 120, 71.0486,114.0708);

@RequestMapping(value="", method = RequestMethod.POST)
public String createDog(@ModelAttribute CreateDog dog, Model model) {
return "result";

Sky Sky

I'm not sure what's th:action for. But seems that you have two actions tag in your page, is that right?

You can try to visit the url from browser directly and see if you can get the result.

You can refer to here