qq_33458839
Azrael-zlf
2016-01-27 10:08

关于spring mvc注解的使用,运行tomcat时出错

  • spring

spring-mvc.xml的代码

    <!--开启注解扫描 -->
<context:component-scan base-package="com.tarena"/>

<!--开启MVC注解扫描 -->
<mvc:annotation-driven/>

<!--定义视图解析器ViewResolver -->
<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/"/>
    <property name="suffix" value=".jsp"/>
</bean>

页面的代码

package com.tarena.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/demo")
public class HelloController {
@RequestMapping("/hello.do")
public ModelAndView hello(HttpServletRequest request,
HttpServletResponse response) throws Exception {
System.out.println("Hello, Controller.");
return new ModelAndView("jsp/hello");
}
}

web.xml的代码


springmvc

org.springframework.web.servlet.DispatcherServlet


contextConfigLocation
classpath:spring-mvc.xml

1


springmvc
*.do

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

7条回答