1

I'am using Spring boot and Tomcat7 to build a vehicle management system.

The base path is localhost:8080/vehicle

My server setting:

server.contextPath=/vehicle

My IndexController:

@RequestMapping("/")
public class IndexController extends BaseController {
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String index(Model model) {
        return "redirect:/login";
    }
}

But when I go straight to get this view, my path is ...../login instead of ..../vehicle/login And so it returns 404 Error.

Also when I tried to use return "redirect:/vehicle/login"; it still goes to ...../login.

So what is wrong with my code. Why the server can't recognize the contextPath.

Mix
  • 459
  • 1
  • 7
  • 20
  • Duplicated? with http://stackoverflow.com/questions/29617277/spring-boot-war-external-tomcat-context-path – Ruben Apr 11 '17 at 12:22

1 Answers1

0

In application.properties use : server.servlet.context-path=/contextPath.

Example: server.servlet.context-path=/vehicle

Tomcat Server: In the webapps folder, the context path(vehicle) must be the same as the folder name(vehicle).

Yoni
  • 1,370
  • 7
  • 17