100分求救,急 getHibernateTemplate().getSessionFactory().getCurrentSession(); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我按你的方法试过了,还是不行。 同样是获取不到session 是没取道session但没看出来为什么. java一块贴上来了,看着的眼有点 晕了,呵呵,xml, 我把所有的配置文件都给出来吧------------applicationContext.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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"> </property> <property name="url" value="jdbc:microsoft:sqlserver://localhost:1433"> </property> <property name="username" value="sa"></property> <property name="password" value="123456789zzh"></property> </bean> <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="datasource" /> </property> <property name="hibernateProperties"> <props> <!-- 表示允许自动提交 --> <prop key="hibernate.connection.autocommit">true</prop> <!-- 显示sql语句 --> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.dialect"> org.hibernate.dialect.SQLServerDialect </prop> </props> </property> <property name="mappingResources"> <list> <value>zzh/mybbs/vo/User.hbm.xml</value></list></property></bean> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="userdao" class="zzh.mybbs.dao.UserDao" abstract="true"> </bean> <bean id="userdaoimpl" class="zzh.mybbs.dao.impl.UserDaoImpl" parent="userdao"> <property name="hibernateTemplate"> <ref bean="hibernateTemplate"/> </property> </bean><bean name="/jsp/user" class="zzh.mybbs.struts.action.UserAction"><property name="userdao"><ref bean="userdaoimpl"/></property></bean> </beans>------web.xml<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <filter> <filter-name>EncodingFilter</filter-name> <filter-class> zzh.mybbs.charsetFilter.EncodingFilter </filter-class> <init-param> <param-name>charset</param-name> <param-value>gbk</param-value> </init-param> </filter> <filter-mapping> <filter-name>EncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>opensession</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> </filter> <filter-mapping> <filter-name>opensession</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/classes/applicationContext.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <servlet> <servlet-name>context</servlet-name> <servlet-class> org.springframework.web.context.ContextLoaderServlet </servlet-class> </servlet> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>3</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>3</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>-----------------struts-config.xml<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config> <data-sources /> <form-beans > <form-bean name="userForm" type="zzh.mybbs.struts.form.UserForm" /> </form-beans> <global-exceptions /> <global-forwards /> <action-mappings > <action attribute="userForm" input="/jsp/errors.jsp" name="userForm" parameter="status" path="/jsp/user" scope="request" type="zzh.mybbs.struts.action.UserAction"> <forward name="registersuccess" path="/jsp/index.jsp"></forward> <forward name="registerfailure" path="/jsp/register.jsp"></forward> </action> </action-mappings> <controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"> </controller> <message-resources parameter="zzh.mybbs.struts.ApplicationResources" /><plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml"/></plug-in></struts-config>其余的java程序就不用贴了。应该不会有错。 北京招聘 Java 开发的高级软件工程师 公司招聘 在北京长期工作发展的 Java 开发的高级软件工程师 以及 开发项目组长; 软件工程师4K以上待遇 高级软件工程师至少6K以上,根据能力上不封顶; 公司地点在 青云当代大厦 (联想桥附近) 因为需要扩大招聘渠道,所以在此发贴,在多个招聘网站也有公告,公司 属于外资企业(东方金鸟),符合条件请发简历到邮箱: [email protected] ; 公司目前有C++ JAVA 和 .NET 三个方面开发团队,Java 团队主要负责 运营网站系统 开发,希望有中高级人才一起加盟,共同发展。 希望有机会能一起奋斗!共同成长! 一块一块的看的眼花!~~那就是sessionFactory没初始话了,看下有没有成功的加入配置文件 你的测试类有问题吧?UserDaoImpl user=new UserDaoImpl(); ------这个有不是从spring中得到的对象,自己new出来的话那不是等于没有用spring? UserDaoImpl user=new UserDaoImpl(); ------这个有不是从spring中得到的对象,自己new出来的话那不是等于没有用spring?IoC的机制你更本就不懂.UserDaoImpl 你应该是setter 进去或者后造函数传进去的.. 那只是测试呀,连SESSION都获取不到,当然spring配置就有问题了嘛。 问一个hm.get()和it.next()的返回值问题 谢谢哈 急呀 SSH框架,后台页面根据固定Menu用层来显示内容,求解决!!~~ 求救:2个时间如何比较相差多少分钟多少秒。 Hibernate中的BAG标签有什么用? 求jsp+servlet的问题~~~~~~~~~~~在线中 dom读xml文本节点问题 ! 联合主键 ?= 主键+非空外键 weblogic及EJB属于中间层的吗?( weblogic怎样部署一个ejb?就像deploytool那样 不同页面提交不同form到一个action的方法,return时怎么区分转向哪个页面? 各位大哥帮帮忙JBuilder 9配置出现的问题
同样是获取不到session
但没看出来为什么.
------------applicationContext.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="datasource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.jdbc.sqlserver.SQLServerDriver">
</property>
<property name="url"
value="jdbc:microsoft:sqlserver://localhost:1433">
</property>
<property name="username" value="sa"></property>
<property name="password" value="123456789zzh"></property>
</bean>
<bean id="hibernateInterceptor"
class="org.springframework.orm.hibernate3.HibernateInterceptor">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="datasource" />
</property>
<property name="hibernateProperties">
<props>
<!-- 表示允许自动提交 -->
<prop key="hibernate.connection.autocommit">true</prop>
<!-- 显示sql语句 -->
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>zzh/mybbs/vo/User.hbm.xml</value></list></property></bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="userdao" class="zzh.mybbs.dao.UserDao" abstract="true">
</bean>
<bean id="userdaoimpl" class="zzh.mybbs.dao.impl.UserDaoImpl" parent="userdao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>
<bean name="/jsp/user" class="zzh.mybbs.struts.action.UserAction">
<property name="userdao">
<ref bean="userdaoimpl"/>
</property>
</bean>
</beans>------web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>
zzh.mybbs.charsetFilter.EncodingFilter
</filter-class>
<init-param>
<param-name>charset</param-name>
<param-value>gbk</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>opensession</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>opensession</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
</servlet>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>-----------------struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config>
<data-sources />
<form-beans >
<form-bean name="userForm" type="zzh.mybbs.struts.form.UserForm" /> </form-beans> <global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="userForm"
input="/jsp/errors.jsp"
name="userForm"
parameter="status"
path="/jsp/user"
scope="request"
type="zzh.mybbs.struts.action.UserAction">
<forward name="registersuccess" path="/jsp/index.jsp"></forward>
<forward name="registerfailure" path="/jsp/register.jsp"></forward>
</action>
</action-mappings> <controller
processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
</controller>
<message-resources parameter="zzh.mybbs.struts.ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml"/>
</plug-in>
</struts-config>其余的java程序就不用贴了。应该不会有错。
公司地点在 青云当代大厦 (联想桥附近) 因为需要扩大招聘渠道,所以在此发贴,在多个招聘网站也有公告,公司 属于外资企业(东方金鸟),符合条件请发简历到邮箱: [email protected] ; 公司目前有C++ JAVA 和 .NET 三个方面开发团队,Java 团队主要负责 运营网站系统 开发,希望有中高级人才一起加盟,共同发展。 希望有机会能一起奋斗!共同成长!
那就是sessionFactory没初始话了,看下有没有成功的加入配置文件
UserDaoImpl user=new UserDaoImpl(); ------这个有不是从spring中得到的对象,自己new出来的话那不是等于没有用spring?
IoC的机制你更本就不懂.
UserDaoImpl 你应该是setter 进去或者后造函数传进去的..