如何完成一个生动的ps涂鸦工具在哪里文字效果

springMVC+Hibernate 使用配置 -
- ITeye技术网站
博客分类:
本文描述下 sypro 项目中使用 springMVC+Hibernate配置,初学SpringMVC做下简单整理解。
1.web项目首先我们要使用 web.xml文件将 spring配置引入进来
&?xml version="1.0" encoding="UTF-8"?&
&web-app version="2.5" xmlns="/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="/xml/ns/javaee
/xml/ns/javaee/web-app_2_5.xsd"&
&description&springMvc+hibernate4+easyui&/description&
&display-name&sypro2.02&/display-name&
&context-param&
&param-name&contextConfigLocation&/param-name&
&param-value&classpath:spring.xml,classpath:spring-hibernate.xml,classpath:spring-ehcache.xml,classpath:spring-apacheFtpServer.xml&/param-value&
&/context-param&
&filter-name&openSessionInViewFilter&/filter-name&
&filter-class&org.springframework.orm.hibernate4.support.OpenSessionInViewFilter&/filter-class&
&init-param&
&param-name&singleSession&/param-name&
&param-value&true&/param-value&
&/init-param&
&description&字符集过滤器&/description&
&filter-name&encodingFilter&/filter-name&
&filter-class&org.springframework.web.filter.CharacterEncodingFilter&/filter-class&
&init-param&
&description&字符集编码&/description&
&param-name&encoding&/param-name&
&param-value&UTF-8&/param-value&
&/init-param&
&filter-mapping&
&filter-name&openSessionInViewFilter&/filter-name&
&url-pattern&*.do&/url-pattern&
&/filter-mapping&
&filter-mapping&
&filter-name&encodingFilter&/filter-name&
&url-pattern&/*&/url-pattern&
&/filter-mapping&
&listener&
&description&spring监听器&/description&
&listener-class&org.springframework.web.context.ContextLoaderListener&/listener-class&
&/listener&
&listener&
&description&apache ftp server监听器&/description&
&listener-class&sy.util.ApacheFtpServerListener&/listener-class&
&/listener&
&listener&
&description&Introspector缓存清除监听器&/description&
&listener-class&org.springframework.web.util.IntrospectorCleanupListener&/listener-class&
&/listener&
&description&spring mvc servlet&/description&
&servlet-name&springMvc&/servlet-name&
&servlet-class&org.springframework.web.servlet.DispatcherServlet&/servlet-class&
&init-param&
&description&spring mvc 配置文件&/description&
&param-name&contextConfigLocation&/param-name&
&param-value&classpath:spring-mvc.xml&/param-value&
&/init-param&
&load-on-startup&1&/load-on-startup&
&/servlet&
&servlet-mapping&
&servlet-name&springMvc&/servlet-name&
&url-pattern&*.do&/url-pattern&
&/servlet-mapping&
&session-config&
&session-timeout&3&/session-timeout&
&/session-config&
&welcome-file-list&
&welcome-file&index.jsp&/welcome-file&
&welcome-file&init.jsp&/welcome-file&
&/welcome-file-list&
&error-page&
&error-code&404&/error-code&
&location&/error/404.jsp&/location&
&/error-page&
&error-page&
&error-code&500&/error-code&
&location&/error/500.jsp&/location&
&/error-page&
&distributable /&
&/web-app&
部署applicationContext的xml文件,如果在web.xml中不写任何参数配置信息,默认的路径是”/WEB-INF/applicationContext.xml,在WEB-INF目录下创建的xml文件的名称必须是applicationContext.xml。如果是要自定义文件名可以在web.xml里加入contextConfigLocation如下,在&param-value& &/param-value&里指定相应的xml文件名,如果有多个xml文件,可以写在一起并一“,”号分隔
&display-name&sypro2.02&/display-name&
&context-param&
&param-name&contextConfigLocation&/param-name&
&param-value&classpath:spring.xml,classpath:spring-hibernate.xml,classpath:spring-ehcache.xml,classpath:spring-apacheFtpServer.xml&/param-value&
&/context-param&
&filter-name&openSessionInViewFilter&/filter-name&
&filter-class&org.springframework.orm.hibernate4.support.OpenSessionInViewFilter&/filter-class&
&init-param&
&param-name&singleSession&/param-name&
&param-value&true&/param-value&
&/init-param&
加载contextConfigLocation则交给监听来实现
&listener&
&description&spring监听器&/description&
&listener-class&org.springframework.web.context.ContextLoaderListener&/listener-class&
&/listener&
然后配置springMVC处理请求映射
&description&spring mvc servlet&/description&
&servlet-name&springMvc&/servlet-name&
&servlet-class&org.springframework.web.servlet.DispatcherServlet&/servlet-class&
&init-param&
&description&spring mvc 配置文件&/description&
&param-name&contextConfigLocation&/param-name&
&param-value&classpath:spring-mvc.xml&/param-value&
&/init-param&
&load-on-startup&1&/load-on-startup&
&/servlet&
&servlet-mapping&
&servlet-name&springMvc&/servlet-name&
&url-pattern&*.do&/url-pattern&
&/servlet-mapping&
2.applicationContext.xml 文件常用配置,在该项目中使用的自定义写法 将 applicationContext.xml 重命名为: spring-mvc.xml ,注意如果不使用自定义写法applicationContext.xml则存放在 /WEB-INF/applicationContext.xml目录且不可重命名
applicationContext.xml (spring-mvc.xml) 常用配置如下:
&?xml version="1.0" encoding="UTF-8"?&
&beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc" 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"
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/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&
&!-- 自动扫描controller包下的所有类,使其认为spring mvc的控制器 --&
&context:component-scan base-package="sy.controller" /&
&!-- 避免IE执行AJAX时,返回JSON出现下载文件 --&
&bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"&
&property name="supportedMediaTypes"&
&value&text/charset=UTF-8&/value&
&/property&
&!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 --&
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&
&property name="messageConverters"&
&ref bean="mappingJacksonHttpMessageConverter" /&&!-- json转换器 --&
&/property&
&!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 --&
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/" p:suffix=".jsp" /&
&bean id="multipartResolver"
class="org.springframework.monsMultipartResolver"&
&property name="defaultEncoding"&
&value&UTF-8&/value&
&/property&
&property name="maxUploadSize"&
&value&&/value&&!-- 上传文件大小限制为31M,31* --&
&/property&
&property name="maxInMemorySize"&
&value&4096&/value&
&/property&
&!-- 拦截器 --&
&mvc:interceptors&
&mvc:interceptor&
&mvc:mapping path="/**" /&
&bean class="sy.interceptors.EncodingInterceptor" /&
&/mvc:interceptor&
&mvc:interceptor&
&mvc:mapping path="/**" /&
&bean class="sy.interceptors.AuthInterceptor" /&
&/mvc:interceptor&
&/mvc:interceptors&
spring-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:context="http://www.springframework.org/schema/context"
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
&!-- 引入属性文件 --&
&context:property-placeholder location="classpath:config.properties" /&
&!-- 自动扫描dao和service包(自动注入) --&
&context:component-scan base-package="sy.dao,sy.service" /&
&!-- 引入属性文件 --&
&context:property-placeholder location="classpath:config.properties" /&
项目配置映入属性文件在配置hibenrate数据库配置提供了便利
如下 spring-hibernate.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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
&!-- JNDI方式配置数据源 --&
&!-- &bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"&
&property name="jndiName" value="${jndiName}"&&/property& &/bean& --&
&!-- dbcp数据源 --&
&bean name="dataSource" class="mons.dbcp.BasicDataSource"&
&property name="driverClassName" value="${driverClassName}"&&/property&
&property name="url" value="${url}"&&/property&
&property name="username" value="${username}"&&/property&
&property name="password" value="${password}"&&/property&
&bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&
&property name="dataSource" ref="dataSource" /&
&property name="hibernateProperties"&
&prop key="hibernate.hbm2ddl.auto"&${hibernate.hbm2ddl.auto}&/prop&
&prop key="hibernate.dialect"&${hibernate.dialect}&/prop&
&prop key="hibernate.show_sql"&${hibernate.show_sql}&/prop&
&prop key="hibernate.format_sql"&${hibernate.format_sql}&/prop&
&/property&
&!-- 注解方式配置 --&
&!-- &property name="packagesToScan"& &list& &value&sy.hbm&/value& &/list&
&/property& --&
&!-- hbm方式配置 --&
&property name="mappingDirectoryLocations"&
&value&classpath:sy/hbm&/value&
&/property&
&!-- 配置事务 --&
&bean name="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager"&
&property name="sessionFactory" ref="sessionFactory"&&/property&
&tx:annotation-driven transaction-manager="transactionManager" /&
spring缓存配置
&!-- 开启spring缓存 --&
&cache:annotation-driven cache-manager="cacheManager" /&
&bean id="cacheManagerFactory"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:configLocation="classpath:ehcache.xml" p:shared="false" /&
&bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
p:cacheManager-ref="cacheManagerFactory" /&
浏览 11660
浏览: 71147 次
只有前台页面,参考意义不大
缺少addProperty和create方法
请问一下,这些漏洞用appscan扫描出来以后怎么查看具体漏洞 ...hiberante悲观锁和乐观锁怎么用整合到spring(想用注解的方式)里
悲观锁网上找了半天,全是单个的,没有整合进spring里,难道要先用getHibernateTelmple().getSession(....)先配好了来?
有注解配悲观锁吗?
乐观锁加个@Version好像就ok了,测了下,只要更新数据就会自动加1java - Spring 3.2 + Hibernate 4 OpenSessionInViewFilter - Stack Overflow
Join the Stack Overflow Community
Stack Overflow is a community of 6.9 million programmers, just like you, helping each other.
J it only takes a minute:
I'm a Spring newbie trying my first app.
My hibernate gets closed before the view is rendered and having problems with lazy loaded properties (expected behavior).
I've added the OpenSessionInViewFilter to my web.xml and caused the following:
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
Beforehand It was working fine with the default servlet context config I've had (can someone tell me why?).
So I've added the following:
&context-param&
&param-name&contextConfigLocation&/param-name&
&param-value&
/WEB-INF/springapp-servlet.xml
&/param-value&
&/context-param&
&listener&
&listener-class&org.springframework.web.context.ContextLoaderListener&/listener-class&
&/listener&
The new error went away..but still getting a no session exception from hibernate
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.test.model.Store.categories, could not initialize proxy - no Session
I've put a debug message in one of my controllers and it seems that its being initialized 3 times.
Maybe I have more than one instance of hibernate session factory bean?
My controller methods are marked @Transactional and everything worked until I've attempted to leave the session open to make the lazy fields available for the view.
My full web.xml (with the new context addition, worked fine without it before I've added the hibernate filter):
&?xml version="1.0" encoding="ISO-8859-1"?&
&web-app version="2.4"
xmlns="/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="/xml/ns/j2ee
/xml/ns/j2ee/web-app_2_4.xsd" &
&display-name&
&/display-name&
&description&
Spring Test
&/description&
&context-param&
&param-name&contextConfigLocation&/param-name&
&param-value&
/WEB-INF/springapp-servlet.xml
&/param-value&
&/context-param&
&listener&
&listener-class&org.springframework.web.context.ContextLoaderListener&/listener-class&
&/listener&
&filter-name&hibernateFilter&/filter-name&
&filter-class&org.springframework.orm.hibernate4.support.OpenSessionInViewFilter&/filter-class&
&init-param&
&param-name&sessionFactoryBeanName&/param-name&
&param-value&sessionFactory&/param-value&
&/init-param&
&filter-mapping&
&filter-name&hibernateFilter&/filter-name&
&url-pattern&/*&/url-pattern&
&dispatcher&REQUEST&/dispatcher&
&dispatcher&FORWARD&/dispatcher&
&/filter-mapping&
&servlet-name&springapp&/servlet-name&
&servlet-class&org.springframework.web.servlet.DispatcherServlet&/servlet-class&
&load-on-startup&1&/load-on-startup&
&/servlet&
&servlet-mapping&
&servlet-name&springapp&/servlet-name&
&url-pattern&/&/url-pattern&
&/servlet-mapping&
&error-page&
&error-code&500&/error-code&
&location&/error/500&/location&
&/error-page&
&error-page&
&error-code&404&/error-code&
&location&/resources/pages/error.html&/location&
&/error-page&
&/web-app&
springapp-servlet.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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd"&
&context:component-scan base-package="com.test.web.controllers,com.test.service.impl" /&
&mvc:annotation-driven /&
&mvc:resources mapping="/resources/**" location="/resources/" /&
&bean id="myDataSource" class="mons.dbcp.BasicDataSource" destroy-method="close"&
&property name="driverClassName" value="com.mysql.jdbc.Driver"/&
&property name="url" value="jdbc:mysql://localhost:3306/test?zeroDateTimeBehavior=convertToNull"/&
&property name="username" value="spring"/&
&property name="password" value="test"/&
&bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&
&property name="dataSource" ref="myDataSource"/&
&property name="mappingLocations" value="classpath*:com/test/model/hbm/**/*.hbm.xml" /&
&property name="hibernateProperties"&
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql=true
&/property&
&tx:annotation-driven /&
&bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager"&
&property name="sessionFactory" ref="sessionFactory"/&
&bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"&
&property name="resourceLoaderPath" value="/WEB-INF/templates/"/&
&bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver"&
&property name="cache" value="true"/&
&property name="prefix" value=""/&
&property name="suffix" value=".vm"/&
&property name="layoutUrl" value="index.vm" /&
&!-- if you want to use the Spring Velocity macros, set this property to true --&
&property name="exposeSpringMacroHelpers" value="true"/&
&bean id="multipartResolver"
class="org.springframework.monsMultipartResolver"&
&!-- one of the
the maximum file size in bytes --&
&property name="maxUploadSize" value="" /&
&bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" /&
&bean id="categoryDAO" class="com.test.dao.hibernate.HibernateCategoryDAO"&
&property name="sessionFactory" ref="sessionFactory"&&/property&
&bean id="categoryService" class="com.test.service.Categories" scope="singleton"&
&property name="dao" ref="categoryDAO"&&/property&
&bean id="storeDAO" class="com.test.dao.hibernate.HibernateStoreDAO"&
&property name="sessionFactory" ref="sessionFactory"&&/property&
&bean id="storeService" class="com.test.service.Stores" scope="singleton"&
&property name="dao" ref="storeDAO"&&/property&
&property name="categoryDao" ref="categoryDAO"&&/property&
My controllers where initialized twice, the same config was used by the root ApplicationContext and by the FrameworkServlet.
I've had two contexts initialized.
I've created a config for the root context named springapp.xml and moved all my middle tier configuration there and left my web tier configuration in springapp-servlet.xml
My web.xml now looks like this and everything works fine:
&context-param&
&param-name&contextConfigLocation&/param-name&
&param-value&
/WEB-INF/springapp.xml
&/param-value&
&/context-param&
&listener&
&listener-class&org.springframework.web.context.ContextLoaderListener&/listener-class&
&/listener&
&filter-name&hibernateFilter&/filter-name&
&filter-class&org.springframework.orm.hibernate4.support.OpenSessionInViewFilter&/filter-class&
&init-param&
&param-name&sessionFactoryBeanName&/param-name&
&param-value&sessionFactory&/param-value&
&/init-param&
&filter-mapping&
&filter-name&hibernateFilter&/filter-name&
&url-pattern&/*&/url-pattern&
&dispatcher&REQUEST&/dispatcher&
&dispatcher&FORWARD&/dispatcher&
&/filter-mapping&
&servlet-name&springapp&/servlet-name&
&servlet-class&org.springframework.web.servlet.DispatcherServlet&/servlet-class&
&init-param&
&param-name&contextConfigLocation&/param-name&
&param-value&/WEB-INF/springapp-servlet.xml&/param-value&
&/init-param&
&load-on-startup&1&/load-on-startup&
&/servlet&
&servlet-mapping&
&servlet-name&springapp&/servlet-name&
&url-pattern&/&/url-pattern&
&/servlet-mapping&
To solve the problem in my case it was just missing this line
in the application-context file.
The @Transactional annotation over a method was not taken into account.
Hope it will help someone
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
rev .25469
Stack Overflow works best with JavaScript enabled&>&&>&&>&&>&hibernate乐观锁和悲观锁学习
hibernate乐观锁和悲观锁学习
上传大小:36KB
1 . 首先为 TUser 的 class 描述符添加 optimistic-lock 属性:
&hibernate-mapping&
&class name=&org.hibernate.sample.TUser& table=&t_user& dynamic-update=&true&
dynamic-insert=&true& optimistic-lock=&version&&
&/hibernate-mapping&
optimistic-lock 属性有如下可选取值:
none:无乐观锁
version:通过版本机制实现乐观锁
dirty:通过检查发生变动过的属性实现乐观锁
all:通过检查所有属性实现乐观锁
其中通过 version 实现的乐观锁机制是 Hibernate 官方推荐的乐观锁实现,同时也是 Hibernate 中,目前唯一在数据对象脱离 Session 发生修改的情况下依然有效的锁机制。因此,一般情况下,我们都选择 version 方式作为 Hibernate 乐观锁实现机制。
........展开收缩
综合评分:4(1位用户评分)
所需积分:1
下载次数:5
审核通过送C币
创建者:exileme
创建者:jerryshen
创建者:andy8921
课程推荐相关知识库
上传者其他资源上传者专辑
开发技术热门标签
VIP会员动态
android服务器底层网络模块的设计方法
所需积分:0
剩余积分:720
您当前C币:0
可兑换下载积分:0
兑换下载分:
兑换失败,您当前C币不够,请先充值C币
消耗C币:0
你当前的下载分为234。
hibernate乐观锁和悲观锁学习
会员到期时间:
剩余下载次数:
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可奖励20下载分
被举报人:
举报的资源分:
请选择类型
资源无法下载
资源无法使用
标题与实际内容不符
含有危害国家安全内容
含有反动色情等内容
含广告内容
版权问题,侵犯个人或公司的版权
*详细原因:

我要回帖

更多关于 ps涂鸦工具在哪里 的文章

 

随机推荐