日期:2014-05-20 浏览次数:20793 次
import com.opensymphony.xwork2.ActionSupport; public class AccountAction extends ActionSupport { private AccountDAOImpl accountDAOImpl; public AccountAction(AccountDAOImpl accountDAOImpl) { this.accountDAOImpl=accountDAOImpl; } public String execute() throws Exception { accountDAOImpl.createAccount(0,0); return "ok"; } }
import java.util.HashMap; import org.springframework.dao.DataAccessException; import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport; public class AccountDAOImpl extends SqlMapClientDaoSupport implements AccountDAO //implements AccountDAO { public void createAccount(final int cid,final double balance) throws DataAccessException{ Account account=new Account(); account.setCid(cid); account.setBalance(balance); getSqlMapClientTemplate().insert("insertAccount", account); } public void transferAccount(final int toid,final double amount) throws DataAccessException{ } public void savingMoney(final double amount) throws DataAccessException{ } public void withdrawMoney(final double amount) throws DataAccessException{ } }
<bean id="accountDao" class="cn.jacocc.ssitry.AccountDAOImpl"> <property name="sqlMapClient" ref="sqlMapClient"/> </bean> <bean id="accountAction" class="cn.jacocc.ssitry.AccountAction"> <constructor-arg index="0"> <ref bean="accountDao" /> </constructor-arg> </bean>
<package name="article" extends="struts-default"> <global-results> <result name="message">/message.jsp</result> </global-results> <action name="article_*" class="articleAction" method="{1}"> <result name="list">/article_list.jsp</result> <result name="listAction" type="redirect-action">article_list.do</result> <result name="add">/article_add.jsp</result> </action> </package>