WEB开发网
开发学院软件开发Java spring 3.0 应用springmvc 构造RESTful URL 详细讲... 阅读

spring 3.0 应用springmvc 构造RESTful URL 详细讲解

 2009-09-21 00:00:00 来源:WEB开发网   
核心提示: 2. webapp/WEB-INF/springmvc-servlet.xml配置,使用如下两个class激活@RequestMapping annotationJava代码<beanclass="org.springframework.web.servlet.mvc.annot

2. webapp/WEB-INF/springmvc-servlet.xml配置,使用如下两个class激活@RequestMapping annotation

Java代码   

  <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/> 
  <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>

完整配置

Java代码   

<beans default-autowire="byName"  > 
 
 <!-- 自动搜索@Controller标注的类 --> 
 <context:component-scan base-package="com.**.controller"/> 
 
  <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/> 
 
  <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/> 
 
  <!-- Default ViewResolver --> 
  <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> 
    <property name="prefix" value="/pages"/> 
    <property name="suffix" value=".jsp"></property> 
  </bean> 
   
  <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" p:basename="i18n/messages"/> 
 
  <!-- Mapping exception to the handler view --> 
  <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> 
   <!-- to /commons/error.jsp --> 
    <property name="defaultErrorView" value="/commons/error"/> 
    <property name="exceptionMappings"> 
      <props> 
      </props> 
    </property> 
  </bean> 
     
</beans>

上一页  1 2 3 4 5  下一页

Tags:spring 应用 springmvc

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接