Problems in setting up the Spring project

1

Create a controller called HomeController and put the following settings:

That's good too. After that you have to configure the project so that it can see the page that is in that package:

For this you have to create two classes , respectively:

This setting is common to exist in XML files, but it is being done in Java class , okay, in> by a Java class . So far so good.

  

olâ.

And I did the same with class ProductsController :

Being that, I 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";
    }

TomCat was to put the following URLs:

  

localhost: 8080 / Shop / products / ok

With this URL above, it was to appear the error message 404 , but it would appear in the console eclipse message "loading product" , but that was not what happened, the error message appeared on the page but the message did not appear in console eclipse . p>

Then I tested this URL ;

  

link

And it was for the JSP page, but nothing appears, only the 404 error message.

Where did I go wrong?

    
asked by anonymous 15.10.2015 / 18:54

1 answer

2

You are using products / ok on save return and you do not have a ok.jsp page, create one or change the return .

In the form method you are returning / products / form , remove the first ' / ' and it will bomb, / p>

@RequestMapping("/produtos/form")
public String form(){
    return "products/form";
}
    
16.10.2015 / 03:37