0

My Code:

@Controller
@RequestMapping(value = "/register")
public class RegisterController {

    @RequestMapping(method = RequestMethod.GET)
    public String viewRegistration(Map<String, Object> model) {
        User userForm = new User();    
        model.put("userForm", userForm);

        List<String> professionList = new ArrayList<>();
        professionList.add("Developer");
        professionList.add("Designer");
        professionList.add("IT Manager");
        model.put("professionList", professionList);

        return "Registration";
        }
    }

The error I am getting:

WARNING: No mapping found for HTTP request with URI [/SpringSecurity/register] in DispatcherServlet with name 'dispatcher'

Where on the other class I have a code like this:

@RequestMapping(value = "/admin**", method = RequestMethod.GET)
public ModelAndView adminPage() {

    ModelAndView model = new ModelAndView();
    model.addObject("title", "Spring Security Login Form - Database Authentication");
    model.addObject("message", "This page is for ROLE_ADMIN only!");
    model.setViewName("admin");

    return model;

}

and it works.

I know it's a little different approach, but what is so different that it doesn't work?

M4ver1k
  • 1,505
  • 1
  • 15
  • 26
Ondrej Tokar
  • 4,898
  • 8
  • 53
  • 103

1 Answers1

0

I just had to put it into the correct package.

I had an app config with this line:

@ComponentScan({ "org.maguss.*" })

That defines what packages should spring look into. Since I had my Controller in a different package, it wasn't taken into account.

Ondrej Tokar
  • 4,898
  • 8
  • 53
  • 103