spring/struts/mybatis搭建开发环境
?
?其中java文件夹存放以后编写的java文件,resource文件夹存放service、dao、struts的配置文件,sqlmap文件夹存放编程的sqlmap文件,datasource文件夹存放数据源配置的文件。
? ?2.编写web.xml:
?
?3.applicationContext.xml文件的编写:
?4.配置日志文件log4j.properties:
?6.数据文件配置water3.properties:
?此处注意,mybatis需要配置一个别名文件water_datasource.xml,此文件一定要入如下配置。
?至此,项目基本搭建完毕,下图为所需的包:
?
?附:拦截器配置:?公共类:
//dao基类public class BaseDaoImpl<T, PK extends Serializable> extends SqlSessionTemplate{public BaseDaoImpl(SqlSessionFactory sqlSessionFactory) {super(sqlSessionFactory);}}//public class ModelDrivenActionSupport<T> extends BaseActionSupport implements ScopedModelDriven<T>{/** * */private static final long serialVersionUID = 4711438804682348737L;private T model; private String scope;@Overridepublic T getModel() {return model;}@Overridepublic String getScopeKey() {return scope;}@Overridepublic void setModel(T model) {this.model = model;}@Overridepublic void setScopeKey(String scope) {this.scope = scope;}}//public class BaseActionSupport extends ActionSupport implements SessionAware,ServletRequestAware,ServletResponseAware{/** * */private static final long serialVersionUID = -5514461732932831728L;public static final String LIST = "list";public static final String SAVE = "save";public static final String NORESULT = "noresult";private String priMsg;ActionContext context = ActionContext.getContext();HttpServletRequest request;HttpServletResponse response;@SuppressWarnings("rawtypes")SessionMap session;public String param(String paramName) {return request.getParameter(paramName);}@SuppressWarnings("rawtypes")public void setSession(Map map) {this.session = (SessionMap) map;}public void setServletRequest(HttpServletRequest request) {this.request = request;}public void setServletResponse(HttpServletResponse response) {this.response = response;}public HttpServletRequest getRequest() {return request;}public HttpServletResponse getResponse() {return response;}public SessionMap getSession() {return session;}public String getPriMsg() {return priMsg;}public void setPriMsg(String priMsg) {this.priMsg = priMsg;}}?