wangliyun222
鸟枪手
采纳率50%
2017-06-20 10:06

springmvc 入门 controller /index返回index.jsp

2
已采纳

logbak: 17:22:30.105 o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcher' processing GET request for [/hello/index]
logbak: 17:22:30.106 o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /index
logbak: 17:22:30.111 o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/index]
logbak: 17:22:30.111 o.s.w.s.h.SimpleUrlHandlerMapping - Mapping [/index] to HandlerExecutionChain with handler [org.springframework.web.servlet.mvc.ParameterizableViewController@6b54afba] and 1 interceptor
logbak: 17:22:30.112 o.s.web.servlet.DispatcherServlet - Last-Modified value for [/hello/index] is: -1
本次请求处理时间为:10ms
logbak: 17:22:30.115 o.s.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name '/index'; URL [/WEB-INF/classes/views//index.jsp]] in DispatcherServlet with name 'dispatcher'
logbak: 17:22:30.118 o.s.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/classes/views//index.jsp] in InternalResourceView '/index'
logbak: 17:22:30.120 o.s.web.servlet.DispatcherServlet - Successfully completed request

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • m0_37672234 小静ya 4年前
       <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
            <property name="prefix" value="/" />
            <property name="suffix" value=".jsp" />
            <property name="contentType">
                <value>text/html;charset=UTF-8</value>
            </property>
        </bean>
    
    点赞 1 评论 复制链接分享
  • m0_37672234 小静ya 4年前

    你的配置文件写好没得?要配置 好了才能直接跳转到index.jsp页面上。

    点赞 2 评论 复制链接分享
  • weixin_38374620 JessyJ_C 4年前

    controller的类和web.xml贴出来,再继续帮你看看,
    Forwarding to resource [/WEB-INF/classes/views//index.jsp] in InternalResourceView '/index'

    点赞 评论 复制链接分享
  • wangliyun222 鸟枪手 4年前

    两个配置文件
    @Configuration
    @EnableWebMvc// 1
    @EnableScheduling
    @ComponentScan("com.wisely.highlight_springmvc4")
    public class MyMvcConfig extends WebMvcConfigurerAdapter {// 2

    @Bean
    public InternalResourceViewResolver viewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setPrefix("/WEB-INF/classes/views/");
        viewResolver.setSuffix(".jsp");
        viewResolver.setViewClass(JstlView.class);
        return viewResolver;
    }
    

    }

    public class WebInitializer implements WebApplicationInitializer {//1

    @Override
    public void onStartup(ServletContext servletContext)
            throws ServletException {
        AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
        ctx.register(MyMvcConfig.class);
        ctx.setServletContext(servletContext); //2
    
        Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); //3
        servlet.addMapping("/");
        servlet.setLoadOnStartup(1);
        servlet.setAsyncSupported(true);//1
    }
    

    }

    点赞 评论 复制链接分享

相关推荐