Q:

Springboot @Controller cannot be invoked, but @RestController works

My controller has been annotated with @Controller and it cannot be invoked
- The browser shows

There was an unexpected error (type=Not Found, status=404).

But, if it is annotated with @RestController, then it works. My SpringBoot version:1.5.3.RELEASE
My Controller : (in com.sbootsecurityjsp.controller)
@Controller
public class LoginController {    
    @RequestMapping(value = "/login", method= RequestMethod.GET )
    public String login() {
        return "Login Controller";
    }   
}

Main Class: (in com.sbootsecurityjsp)
@SpringBootApplication(scanBasePackages = {"com.sbootsecurityjsp"}) 
public class SbootSecurityJspApplication {    
    public static void main(String[] args) {
        SpringApplication.run(SbootSecurityJspApplication.class, args);
    }
}

I am curious why the @Controller cannot work if the @RestController annotation works. If component scan is not working, @RestController also should not work. I have added scanbasePackages too. Even without scanbasePackages, it does not work.
By the way, when the app starts, the logs also show a line as following:  
INFO 532 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login],methods=[GET]}" onto public java.lang.String com.sbootsecurityjsp.controller.LoginController.login()

Why @Controller is used is to differentiate requests to pages and rest calls. Please correct me if I am wrong. My idea is to use @RestController s for REST requests, on the other hand @Controller for pages related requests- redirecting to JSP or any logics related to views. Is it a bad practice ? 

A:

Why does it return a 404 when I use @Controller annotation?
When using @Controller, Spring expects the String you return in @RequestMapping methods to correspond to the page you want to redirect the user to. 
@RequestMapping(value = "/login", method= RequestMethod.GET )
public String login() {
    return "Login Controller";
}

Here, Spring will try to redirect the user to Login Controller.jsp, which cannot be found and thus returns a 404.
Why does it not return 404 when I use @RestController
When using @RestController, the String you return is not mapped to any page. Instead, Spring just transforms it to e.g. a JSON response. This is why this doesn't give you a 404.
Proposed solution
If you have a jsp page called login.jsp, simply return "login":
@RequestMapping(value = "/login", method= RequestMethod.GET )
public String login() {
    return "login";
}

