此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【gj_wrxz】截止到2008-06-29 18:38:16的历史汇总数据(不包括此帖):
发帖数:29 发帖分:940
结贴数:29 结贴分:940
未结数:0 未结分:0
结贴率:100.00% 结分率:100.00%
敬礼!
楼主【gj_wrxz】截止到2008-06-29 18:38:16的历史汇总数据(不包括此帖):
发帖数:29 发帖分:940
结贴数:29 结贴分:940
未结数:0 未结分:0
结贴率:100.00% 结分率:100.00%
敬礼!
解决方案 »
- 求救(急):java poi导出word 如何设置word模式为页面视图
- 我的智囊团出错J2EE
- ?action
- 那位高手能指点一下~~~ 多谢了
- 怎样在Weblogic8.1中自动创建Domain并部署应用?
- J2EE应用程序中的纵向和横向如何理解?
- hibernate.cfg.xml的问题关于数据库用户跟数据库的关系(急)
- 请问STRUTS,Hibernate,Spring的下载地址?
- 问一个tomcat向weblogic移植的问题
- 关于weblogic中连接sqlserver的问题,就使搞不定,我用的是sqlserver中文企业版
- Struts的表单提交问题
- sessionbean 未绑定的问题
接口那部分代码没有贴applicationContext.xml<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><!--
hibernate + spring :数据库连接、数据层、服务层、事务、通用事务规则、具体事务规则
struts + spring :Actions
--><beans>
<!-- 数据库连接 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:/hibernate.cfg.xml</value>
</property>
</bean> <!-- 数据层 -->
<bean id="userInfoDaoImpl" class="dyy.aop2.dao.UserInfoDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean> <!-- 服务层 -->
<bean id="userInfoServiceImpl"
class="dyy.aop2.service.UserInfoServiceImpl">
<property name="operateDatabase">
<ref bean="userInfoDaoImpl" />
</property>
</bean> <!-- 事务 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean> <!-- 通用事务规则 -->
<bean id="baseTransactionProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!-- 具体事务 -->
<bean id="userInfoService" parent="baseTransactionProxy">
<property name="target">
<ref bean="userInfoServiceImpl"/>
</property>
</bean>
<!-- Actions -->
<bean name="/user" class="dyy.aop2.struts.action.UserAction" singleton="true">
<property name="service">
<ref bean="userInfoService"/>
</property>
</bean>
</beans>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="dyy.aop2.struts.form.UserForm" /> </form-beans> <global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="userForm"
input="/index.jsp"
name="userForm"
parameter="method"
path="/user"
scope="request"
type="org.springframework.web.struts.DelegatingActionProxy" /> </action-mappings> <message-resources parameter="dyy.aop2.struts.ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="classpath:/applicationContext.xml"/>
</plug-in>
</struts-config>
UserInfoDaoImpl.java 对应 userdao package dyy.aop2.dao;import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;import dyy.entity.UserInfo;public class UserInfoDaoImpl extends HibernateDaoSupport implements
IUserInfoDao { public void addUser(UserInfo user) throws DataAccessException {
super.getHibernateTemplate().save(user);
}}UserInfoServiceImpl.java 对应 userbiz package dyy.aop2.service;import org.springframework.dao.DataAccessException;import dyy.aop2.dao.IUserInfoDao;
import dyy.entity.UserInfo;public class UserInfoServiceImpl implements IUserInfoService { private IUserInfoDao operateDatabase; public IUserInfoDao getOperateDatabase() {
return operateDatabase;
} public void setOperateDatabase(IUserInfoDao operateDatabase) {
this.operateDatabase = operateDatabase;
} public void addUser(UserInfo user) throws DataAccessException {
operateDatabase.addUser(user);
}}UserAction 对应 useraction/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package dyy.aop2.struts.action;import java.lang.reflect.InvocationTargetException;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;import dyy.aop2.service.IUserInfoService;
import dyy.aop2.struts.form.UserForm;
import dyy.entity.UserInfo;/**
* MyEclipse Struts Creation date: 06-06-2008
*
* XDoclet definition:
*
* @struts.action path="/user" name="userForm" input="/index.jsp"
* parameter="method" scope="request" validate="true"
*/
public class UserAction extends DispatchAction {
private IUserInfoService service; /*
* Generated Methods
*/ public IUserInfoService getService() {
return service;
} public void setService(IUserInfoService service) {
this.service = service;
} /**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward doAddUser(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UserForm userForm = (UserForm) form;
UserInfo user = new UserInfo();
try {
BeanUtils.copyProperties(user, userForm);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} service.addUser(user); return null;
}
}
报 404 ,找不到servlet action <bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://localhost/crm?useUnicode=true&characterEncoding=GBK">
</property>
<property name="username" value="root"></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.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>...</value>
</list>
</property>
</bean>