11 Replies Latest reply on Feb 17, 2015 3:28 AM by Vidmantas Banaitis

    spring mvc dispatcher servlet mapping

    poor thing Newbie

      Hello i have a trouble with spring mvc in jboss 7.1.1.Final. HomeController returns simple hello world jsp page.

       

       

      public class WebConfig implements WebApplicationInitializer {

                    @Override

                    public void onStartup(ServletContext servletContext) throws ServletException {

                        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();

                        rootContext.register(ApplicationContext.class);

                        ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(rootContext));

                        dispatcher.setLoadOnStartup(1);

                        dispatcher.addMapping("/");

                        servletContext.addListener(new ContextLoaderListener(rootContext));

                    }

       

      Controller:

       

      @Controller

      public class HomeController {

          protected static final String INDEX_VIEW = "index";

          @RequestMapping(value = "/", method = RequestMethod.GET)

          public String showPage() {

              return INDEX_VIEW;

          }

      }

       

       

      jboss-web.xml:

       

      <jboss-web>

          <context-root>/</context-root>

      </jboss-web>

       

       

      accessing localhost:8080 results in 404. I've set jboss logging to debug, and i don't see "dispatcher proccessing get request" kinda thing. Does this mean servlet is not mapped? Everything works fine on tomcat 7 and jetty 8.