本文主要介绍使用注解方式配置的spring mvc,包括数据访问层的实现
l配置:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="/2001/XMLSchema-instance" xmlns="java.sun/xml/ns/javaee" xmlns:web="java.sun/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="java.sun/xml/ns/javaee java.sun/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>s3h3</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext*.xml</param-value>
</context-param>
<listener>
<listener-class>org.t.ContextLoaderListener</listener-class>
</listener>
<web-app xmlns:xsi="/2001/XMLSchema-instance" xmlns="java.sun/xml/ns/javaee" xmlns:web="java.sun/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="java.sun/xml/ns/javaee java.sun/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>s3h3</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext*.xml</param-value>
</context-param>
<listener>
<listener-class>org.t.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
spring-servlet,主要配置controller的信息
<?xml version="1.0" encoding="UTF-8"?>springmvc的注解有哪些
<beans xmlns="/schema/beans"
xmlns:xsi="/2001/XMLSchema-instance" xmlns:p="/schema/p"
xmlns:context="/schema/context"
xsi:schemaLocation="/schema/beans /schema/beans/spring-beans-3.0.xsd
/schema/aop /schema/aop/spring-aop-3.0.xsd
/schema/tx /schema/tx/spring-tx-3.0.xsd
/schema/context /sc
<beans xmlns="/schema/beans"
xmlns:xsi="/2001/XMLSchema-instance" xmlns:p="/schema/p"
xmlns:context="/schema/context"
xsi:schemaLocation="/schema/beans /schema/beans/spring-beans-3.0.xsd
/schema/aop /schema/aop/spring-aop-3.0.xsd
/schema/tx /schema/tx/spring-tx-3.0.xsd
/schema/context /sc
hema/context/spring-context-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="ller" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/view/" p:suffix=".jsp" />
<context:annotation-config />
<context:component-scan base-package="ller" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/view/" p:suffix=".jsp" />
<bean id="multipartResolver"
class="org.springframework.web.multipartmons.CommonsMultipartResolver"
p:defaultEncoding="utf-8" />
</beans>
class="org.springframework.web.multipartmons.CommonsMultipartResolver"
p:defaultEncoding="utf-8" />
</beans>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论