Problems in configuring the Spring project

Asked

Viewed 427 times

1

Create a controller called Homecontroller and put the following settings:

So far so good. After that you have to configure the project to see the page that is in this package:

For that you have to create two classes, respectively:

This setting is common to exist in files XML, but it’s being done in java class, all right, it’s a trend to replace XML by a java class. So far so good.

When I put to compile I succeed in receiving this message to the class Homecontroller:

olâ.

And I did the same with class Productscontroller:

And I’ve made the following modifications:

@Controller
public class ProductsController {

    @RequestMapping("/produtos/")
    public String save(){
        System.out.println("carregando produto");
        return "products/ok";
    }

    @RequestMapping("/produtos/form")
    public String form(){
        return "/products/form";
    }

At the beginning of the Tomcat was to place the following URL s:

localhost:8080/Shop/products/ok

With that URL above, was to pop up the error message 404, but would appear in the console of eclipse the message "carrying product", but that’s not what happened, the error message appeared on the page but did not appear the message on console of eclipse.

Then I tested that URL;

http://localhost:8080/Store/products/form

And the page was supposed to appear JSP, but nothing appears, only the error message 404.

I wonder where I went wrong ?

  • That question is the same as this?

  • no, there’s only one difference, I had started all over again and did not put connection configuration.

1 answer

2


You are using products/ok on the return of save and you don’t have a page ok.jsp, create one or change the return.

Already in the method form you are returning /products/form, take the first '/' and it’s going to rock, like this:

@RequestMapping("/produtos/form")
public String form(){
    return "products/form";
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.