《maven2+struts2+spring3 使用maven一步步搭建ssi ssh框架》由会员分享,可在线阅读,更多相关《maven2+struts2+spring3 使用maven一步步搭建ssi ssh框架(13页珍藏版)》请在金锄头文库上搜索。
1、Maven + struts+ spring版本号:maven 2 Struts 2.1.8.1 Spring 3.0.0.RELEASE接着上个文档配置 maven2 + struts2(见 http:/ spring 加进去。项目创建路径图Web.xml SSH_protoencodingFilterorg.springframework.web.filter.CharacterEncodingFilterencodingutf-8contextConfigLocationclasspath*:applicationContext-services.xmlorg.springframewo
2、rk.web.context.ContextLoaderListenerCharacterEncodingFilterorg.springframework.web.filter.CharacterEncodingFilterencodingUTF-8forceEncodingtruestruts-cleanuporg.apache.struts2.dispatcher.ActionContextCleanUpstruts2 org.apache.struts2.dispatcher.FilterDispatcherstruts2 /*applicationContext-services.x
3、mlfront-context.xmlPom.xml4.0.0my.webcatwar1.0webmars Ryan开发测试 +8mars whjzuiai开发 +8 com.springsource.repository.bundles.release EBR Spring Release Repository http:/ com.springsource.repository.bundles.external EBR External Release Repository http:/ 3.0.0.RELEASE 1.6.42.1.8.1junitjunit3.8.1testjavax.
4、servlet servlet-api 2.4 providedjavax.servletjsp-api2.0providedorg.slf4jslf4j-api$org.slf4j.versionorg.slf4jslf4j-log4j12$org.slf4j.versionorg.slf4jjul-to-slf4j$org.slf4j.versionorg.apache.strutsstruts2-core$org.strtus.versionorg.apache.strutsstruts2-tiles-plugin$org.strtus.versionorg.apache.strutss
5、truts2-spring-plugin$org.strtus.versionasm asm-commons 2.2.3asmasm2.2.3commons-iocommons-io20030203.000550org.springframeworkorg.springframework.core$spring.versionorg.springframeworkorg.springframework.web$spring.versionorg.springframeworkorg.springframework.transaction$spring.versionorg.springfram
6、eworkorg.springframework.orm$spring.versionorg.springframeworkorg.springframework.jdbc$spring.versionorg.springframeworkorg.springframework.web.servlet$spring.versionorg.springframeworkorg.springframework.context$spring.versionorg.springframeworkorg.springframework.aop$spring.versionorg.springframew
7、orkorg.springframework.expression$spring.versionorg.springframeworkorg.springframework.test$.sf.cglib2.1.3org.apache.tilestiles-jsp2.0.4javax.servletjstl1.1.0org.apache.maven.plugins maven-eclipse-plugintrue true 2.0org.codehaus.mojo tomcat-maven-pluginmaven-javadoc-pluginhttp:/ UTF-8org.mortbay.jet
8、ty maven-jetty-plugin 6.1.6maven-compiler-plugin1.6 1.6 UTF-8org.codehaus.mojo surefire-report-maven-pluginmaven-javadoc-pluginhttp:/ UTF-8UTF-8 UTF-8Struts.xmlWEB-INF/login.jspWEB-INF/login.jspLogback.xml INFOACCEPTDENY%-4relative %thread %-5level %logger30 - %msg%nUserDaopackage com.web.www.dao.im
9、pl;import com.web.www.dao.IUserDao;/* Created by IntelliJ IDEA.* User: ryan* Date: 11-11-19* Time: 下午 10:51*/ public class UserDao implements IUserDaoOverridepublic boolean save() return false; /To change body of implemented methods use File | Settings | File Templates.Overridepublic boolean update(
10、) System.out.print(“-update-“);return false; /To change body of implemented methods use File | Settings | File Templates.Overridepublic boolean delete() return false; /To change body of implemented methods use File | Settings | File Templates.Overridepublic boolean get() return false; /To change bod
11、y of implemented methods use File | Settings | File Templates. UserAction package com.web.www.view;import com.opensymphony.xwork2.ActionSupport; import com.web.www.dao.IUserDao; import com.web.www.dao.impl.UserDao; import org.springframework.context.ApplicationContext; import org.springframework.con
12、text.support.ClassPathXmlApplicationContext;/* Created by IntelliJ IDEA.* User: ryan* Date: 11-11-19* Time: 下午 10:53*/ public class UserAction extends ActionSupportprivate IUserDao userDao;public String execute()/ ApplicationContext context = new ClassPathXmlApplicationContext( /“applicationContext-services.xml“); /UserDao userDao = (UserDao) context.getBean(“userDao“); /obj.printHello();userDao.update();return SUCCESS;public IUserDao getUserDao() return userDao;public void setUserDao(IUserDao userDao) this.userDao = userDao; 使用 jetty 插件运行项目运行结果后台打印 “-update-” 表示 spring 成功