spring配置ibatis后,使用setSqlmapclienttemplate对象为空,代码如下,请教大神帮忙解答,谢谢 45
applicationcontext.xml<beanid="SqlMapClient"class="org.springframework.orm.ibatis.Sql...
applicationcontext.xml
<bean id="SqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="/WEB-INF/sqlMapConfig.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="sqlMapClientTemplate"
class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient">
<ref bean="SqlMapClient" />
</property>
</bean>
<bean id="Loginservise" class="com.yuhang.servise.Loginservise">
<property name="sqlmapclienttemplate" ref="sqlMapClientTemplate"></property>
</bean>
Loginservise.java
private SqlMapClientTemplate sqlmapclienttemplate;
public void setSqlmapclienttemplate(SqlMapClientTemplate sqlmapclienttemplate) {
this.sqlmapclienttemplate = sqlmapclienttemplate;
}
public SqlMapClientTemplate getSqlmapclienttemplate() {
return sqlmapclienttemplate;
}
int count=0;
public boolean login(String name,String pass){
Loginbean login =new Loginbean();
login.setUsername(name);
login.setPassword(pass);
login.setFlag(1);
try{
count=(Integer) sqlmapclienttemplate.queryForObject("getlogin",login);
System.out.print("...................................");
}catch(Exception e){
e.printStackTrace();
} 展开
<bean id="SqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="/WEB-INF/sqlMapConfig.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="sqlMapClientTemplate"
class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient">
<ref bean="SqlMapClient" />
</property>
</bean>
<bean id="Loginservise" class="com.yuhang.servise.Loginservise">
<property name="sqlmapclienttemplate" ref="sqlMapClientTemplate"></property>
</bean>
Loginservise.java
private SqlMapClientTemplate sqlmapclienttemplate;
public void setSqlmapclienttemplate(SqlMapClientTemplate sqlmapclienttemplate) {
this.sqlmapclienttemplate = sqlmapclienttemplate;
}
public SqlMapClientTemplate getSqlmapclienttemplate() {
return sqlmapclienttemplate;
}
int count=0;
public boolean login(String name,String pass){
Loginbean login =new Loginbean();
login.setUsername(name);
login.setPassword(pass);
login.setFlag(1);
try{
count=(Integer) sqlmapclienttemplate.queryForObject("getlogin",login);
System.out.print("...................................");
}catch(Exception e){
e.printStackTrace();
} 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏45(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询