當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
SpringMVC下的基本配置
生活随笔
收集整理的這篇文章主要介紹了
SpringMVC下的基本配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
application.xml
<!--?包含事務以及開啟注解?--> <?xml?version="1.0"?encoding="UTF-8"?> <beans?xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"?xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop"?xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/tx??http://www.springframework.org/schema/tx/spring-tx-2.5.xsd??http://www.springframework.org/schema/aop???http://www.springframework.org/schema/aop/spring-aop-2.5.xsd??http://www.springframework.org/schema/context?????http://www.springframework.org/schema/context/spring-context-2.5.xsdhttp://www.springframework.org/schema/mvc???http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd??"><!--?事務bean?--><bean?id="txManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property?name="sessionFactory"?ref="sessionFactory"></property></bean><!--?鏈接點?--><tx:advice?id="txAvice"?transaction-manager="txManager"><tx:attributes><tx:method?name="find*"?propagation="NOT_SUPPORTED"read-only="true"?/><tx:method?name="paging"?propagation="NOT_SUPPORTED"read-only="true"?/><tx:method?name="q*"?propagation="NOT_SUPPORTED"?read-only="true"?/><tx:method?name="save*"?propagation="REQUIRED"?/><tx:method?name="add*"?propagation="REQUIRED"?/><tx:method?name="keep*"?propagation="REQUIRED"?/><tx:method?name="d*"?propagation="REQUIRED"?/><tx:method?name="update*"?propagation="REQUIRED"?/><tx:method?name="remove*"?propagation="REQUIRED"?/><tx:method?name="upd*"?propagation="REQUIRED"?/></tx:attributes></tx:advice><aop:config><aop:pointcut?expression="execution(*?com.houpusvse.oa.service.impl.*.*(..))"id="myPoin"?/><aop:advisor?advice-ref="txAvice"?pointcut-ref="myPoin"?/></aop:config><bean?id="dataSource"?class="org.apache.commons.dbcp.BasicDataSource"><property?name="driverClassName"?value="com.mysql.jdbc.Driver"></property><property?name="url"?value="jdbc:mysql://localhost:3306/oa"></property><property?name="username"?value="root"></property><property?name="password"?value="mysql"></property></bean><bean?id="sessionFactory"class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"><property?name="dataSource"><ref?bean="dataSource"?/></property><property?name="hibernateProperties"><props><prop?key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop></props></property><property?name="annotatedClasses"><list><!--?實體部分由Hibernate方向工程自動生成?--><value>com.houpusvse.oa.entity.Module</value><value>com.houpusvse.oa.entity.Pware</value><value>com.houpusvse.oa.entity.Premiums</value><value>com.houpusvse.oa.entity.Carpurchase</value><value>com.houpusvse.oa.entity.Structure</value><value>com.houpusvse.oa.entity.Carbrands</value><value>com.houpusvse.oa.entity.Groups</value><value>com.houpusvse.oa.entity.Maction</value><value>com.houpusvse.oa.entity.Purchase</value><value>com.houpusvse.oa.entity.Grule</value><value>com.houpusvse.oa.entity.Cssdetails</value><value>com.houpusvse.oa.entity.Carsellservice</value><value>com.houpusvse.oa.entity.Depot</value><value>com.houpusvse.oa.entity.Carsnries</value><value>com.houpusvse.oa.entity.Carware</value><value>com.houpusvse.oa.entity.Ppurchase</value><value>com.houpusvse.oa.entity.Jtitle</value><value>com.houpusvse.oa.entity.Carwaredetails</value><value>com.houpusvse.oa.entity.Client</value><value>com.houpusvse.oa.entity.Pwdetails</value><value>com.houpusvse.oa.entity.Post</value><value>com.houpusvse.oa.entity.Usergroup</value><value>com.houpusvse.oa.entity.Psellout</value><value>com.houpusvse.oa.entity.Users</value><value>com.houpusvse.oa.entity.Carout</value><value>com.houpusvse.oa.entity.Pcarout</value></list></property></bean><!--?注解?--><mvc:annotation-driven?/><context:annotation-config></context:annotation-config><context:component-scan?base-package="com.houpusvse.oa"></context:component-scan></beans>spring-servlet.xml
<!--?包含開啟注解,json類型轉換,亂碼,視圖控制器,滿足一般開發所需?--> <?xml?version="1.0"?encoding="UTF-8"?> <beans?xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"?xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:util="http://www.springframework.org/schema/util"xsi:schemaLocation="???http://www.springframework.org/schema/beans???http://www.springframework.org/schema/beans/spring-beans-3.0.xsd???http://www.springframework.org/schema/context???http://www.springframework.org/schema/context/spring-context-3.0.xsd??http://www.springframework.org/schema/util???http://www.springframework.org/schema/util/spring-util-3.0.xsd??http://www.springframework.org/schema/mvc???http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"><context:component-scan?base-package="com.houpusvse.oa.controller"?/><!--?ViewResolver?--><beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver"><property?name="viewClass"value="org.springframework.web.servlet.view.JstlView"?/><property?name="prefix"?value="/WEB-INF/jsp/"?/><property?name="suffix"?value=".jsp"?/></bean><beanclass="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"?/><beanclass="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"><property?name="messageConverters"><util:list?id="beanList"><ref?bean="mappingJacksonHttpMessageConverter"?/></util:list></property></bean><bean?id="mappingJacksonHttpMessageConverter"class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"><property?name="supportedMediaTypes"><list><value>text/html;charset=UTF-8</value></list></property></bean><bean?id="multipartResolver"?class="org.springframework.web.multipart.commons.CommonsMultipartResolver"></bean><context:annotation-config/>??</beans>基本就是這樣,忘記的時候可以拿來用用........
轉載于:https://blog.51cto.com/idlong/1687657
總結
以上是生活随笔為你收集整理的SpringMVC下的基本配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Handler(上)——Mars And
- 下一篇: struts文件上传,获取文件名和文件类