N
N
Nightmare0582021-11-03 02:42:23
Spring
Nightmare058, 2021-11-03 02:42:23

Why is text being returned instead of a pattern?

I want to return the template through the controller, but for some reason the text is returned. Everything seems to be like in the guide from the Spring website.
Tell me, please, what could be the problem?

package com.example.test.controller;

import com.example.test.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RegistrationController {
    @GetMapping("/")
    public String greeting() {
        return "index";
    }

    @PostMapping("/registrtion")
    public User registration(@RequestBody User user) {
        return user;
    }
}


6181ccc16311e147584238.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2021-11-03
@Nightmare058

Good afternoon!
Not right:

@RestController
public class RegistrationController {

Should be:
@Controller
public class RegistrationController {

Read about:
https://www.baeldung.com/spring-controller-vs-rest...
Then another error:
your POST request runs to registration
A in the controller:
@PostMapping("/registrtion")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question