今天刚到公司开始第一天实习。要求用MyEclipse手动配置SSH 琢磨了半天,整理了下:
struts2配制:
1.导入: commons-logging-1.0.4.jar xwork-2.0.4.jar freemarker-2.3.8.jar ognl-2.6.11.jar struts2-core-2.0.11.jar struts2-spring-plugin-2.0.11.jar //不用spring不引入 2.改写web.xml,在其中加入以下几行 <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 3.在src下建立struts.xml,写入: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <include file="struts-default.xml"/> </struts> 4.添加spring框架 勾中前4个和spring2.0 web Liberarys 选中Cope to lib 5.添加hibernate框架 勾中前3个 选中copy to lib 6.调整包: 把MyEclipse创建spring2时候生成的commons-collections2.11删除 另导入两个jar包commons-collections.jar,commons-pool-1.4.jar 7.再次修改web.xml <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/classes/applicationContext.xml</param-value> </context-param> <!-- 下面也是spring2的配置 --> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> 8.改写struts.xml 加入: 是在后面的spring2配置中用到意思是把控制交给spring2 <constant name="struts.objectFactory" value="spring" /> 9.在applicationContext.xml中加入 <bean id="hello" class="action.HelloAction"> </bean> 10.在struts.xml中改写 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.objectFactory" value="spring" /> <include file="struts-default.xml"/> <package name="aa" extends="struts-default" namespace="/users"> <action name="hello" class="hello"> <result name ="ok" >/ok.jsp </result > </action> </package></struts>