[size=14px][size=12px]在ssh2项目整合过程中遇到一个问题:
java 代码:
public class LoginAction extends ActionSupport {
private ILoginManager iLoginManager;
private Customer customer;
private String username;
private String password; public void setILoginManager(ILoginManager loginManager) {
iLoginManager = loginManager;
} public ILoginManager getILoginManager() {
return iLoginManager;
}
//用户登录
public String customerLogin() throws Exception { System.out.println("username = " + username);
System.out.println("password = " + password);
System.out.println("iLoginManager = " + iLoginManager); Customer customer = new Customer();
customer.setUsername(username);
customer.setPassword(password); if (iLoginManager.login(customer)) {
return "success";
}
if(username != null && password != null){
return "success";
} //PropertyConfigurator.configure("log4j.properties");
//logger.debug("111111111111111");
return "loginfail";
}
}
上面标红的地方就是提示 iLoginManager 为空spring 配置文件代码:applicationContext-action.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:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-2.5.xsd"> <bean id="userLogin" class="com.z2sci.soa.web.action.LoginAction">
<property name="ILoginManager" ref="ILoginManager" />
</bean></beans>applicationContext-bean.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:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-2.5.xsd">
<bean id="iLoginDao" class="com.z2sci.soa.dao.impl.LoginDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="ILoginManager" class="com.z2sci.soa.manager.impl.LoginManagerImpl">
<property name="iLoginDao" ref="iLoginDao" />
</bean>
</beans>applicationContext-commons.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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-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/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- 配置SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean> <!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean> <!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice> <!-- 配置哪些类哪些方法使用事务 -->
<aop:config>
<aop:pointcut id="allManagerMethod"
expression="execution(* com.z2sci.soa.dao.impl.*.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="allManagerMethod" />
</aop:config>
</beans>
[/size][/size]麻烦大家帮我分析一下到底是怎么回事,谢谢了!
java 代码:
public class LoginAction extends ActionSupport {
private ILoginManager iLoginManager;
private Customer customer;
private String username;
private String password; public void setILoginManager(ILoginManager loginManager) {
iLoginManager = loginManager;
} public ILoginManager getILoginManager() {
return iLoginManager;
}
//用户登录
public String customerLogin() throws Exception { System.out.println("username = " + username);
System.out.println("password = " + password);
System.out.println("iLoginManager = " + iLoginManager); Customer customer = new Customer();
customer.setUsername(username);
customer.setPassword(password); if (iLoginManager.login(customer)) {
return "success";
}
if(username != null && password != null){
return "success";
} //PropertyConfigurator.configure("log4j.properties");
//logger.debug("111111111111111");
return "loginfail";
}
}
上面标红的地方就是提示 iLoginManager 为空spring 配置文件代码:applicationContext-action.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:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-2.5.xsd"> <bean id="userLogin" class="com.z2sci.soa.web.action.LoginAction">
<property name="ILoginManager" ref="ILoginManager" />
</bean></beans>applicationContext-bean.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:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-2.5.xsd">
<bean id="iLoginDao" class="com.z2sci.soa.dao.impl.LoginDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="ILoginManager" class="com.z2sci.soa.manager.impl.LoginManagerImpl">
<property name="iLoginDao" ref="iLoginDao" />
</bean>
</beans>applicationContext-commons.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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-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/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- 配置SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean> <!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean> <!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice> <!-- 配置哪些类哪些方法使用事务 -->
<aop:config>
<aop:pointcut id="allManagerMethod"
expression="execution(* com.z2sci.soa.dao.impl.*.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="allManagerMethod" />
</aop:config>
</beans>
[/size][/size]麻烦大家帮我分析一下到底是怎么回事,谢谢了!
解决方案 »
- 请教一个jar包的问题
- 为什么咱发的帖子没人给回复呢?是没有人会,还是太难?
- 自学struts2一个月的一些看法。
- 怎样实现一个server来集中管理多个server的service。
- radio的选择
- JBuilder2005下调用Tomcat5里配置的JNDI的问题
- 请问有没方法用JMX监控JBOSS运行时产生的信息?
- ServerSocket server
- 写EJB需要那些类库,到哪里去下载这些类,我装了Jbuilder8,但没找到EJB的类库
- 所有的包声明处都有 NullPointerException 的出错提示,高手指教啊!急盼回!
- S2H整合简单的CRUD..抛异常:java.lang.reflect.InvocationTargetException
- spring中使用quartz任务时,jobDataAsMap问题。
与
<bean id="userLogin" class="com.z2sci.soa.web.action.LoginAction">
<property name="ILoginManager" ref="ILoginManager" />
iLoginManager与ILoginManager名字不一致?!你试一下!!
<property name="iLoginManager" ref="ILoginManager" />
</bean>
<property name="iLoginDao" ref="iLoginDao" />
</bean>
你这边配置的跟你类中的属性名不一致。
iLoginManager = loginManager;
}
这个你用自动的生成一下seter吧!可能会好点!