ssh调整xml配置
ssh整合xml配置
配置文件
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>ConnectorServlet</servlet-name> <servlet-class>net.fckeditor.connector.ConnectorServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>ConnectorServlet</servlet-name> <url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern> </servlet-mapping> <!-- fckeditor配置完毕 --> <!-- 配置Spring上下文和监听器 上下文用于找到Spring配置文件applicationContext.xml, 监听器用于当Web应用程序启动,即可监听Spring上下文 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext*.xml,classpath*:applicationContext*.xml</param-value> </context-param> <!-- 配置OpenSessionInView(用于关闭Session),Struts过滤器之前 --> <filter> <filter-name>lazyLoadingFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <filter> <filter-name>action2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>lazyLoadingFilter</filter-name> <!-- 注:Struts2为*.do --> <url-pattern>*.do</url-pattern> </filter-mapping> <!-- END SNIPPET: filter --> <filter-mapping> <filter-name>action2</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <filter-mapping> <filter-name>action2</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <error-page> <error-code>404</error-code> <location>/empty.html</location> </error-page> <login-config> <auth-method>BASIC</auth-method> </login-config> </web-app>
applicationContext.xml(我放在了WEB-INF目录下了)
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <!--我使用了tomcat的jndi数据源,大家可以改成jdbc连接属性--> <property name="jndiName" value="java:comp/env/jdbc/MysqlDB"></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> <!--model一般是工具自动生成--> <value>model/Product.hbm.xml</value> </list> </property> </bean> <bean id="productDao" class="dao.impl.ProductDaoImpl"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="productService" class="service.impl.productServiceImpl"> <property name="dao"> <ref bean="productDao" /> </property> </bean> <bean id="productAction" class="action.ProductAction" scope="prototype"> <property name="service"> <ref bean="productService" /> </property> </bean> <bean id="fileuploadAction" class="action.ajax.FileUpload" scope="prototype"></bean> <!--对sessionFactory事务管理--> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <!--事务管理的类中,具体的方法--> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="*" read-only="false" /> </tx:attributes> </tx:advice> <aop:config> <!--事务管理的类--> <aop:pointcut id="allManagerMethod" expression="execution(* service.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" /> </aop:config> </beans>
struts.xml(项目src的目录下)
<?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.devMode" value="true" /> <constant name="struts.i18n.encoding" value="UTF-8" /> <constant name="struts.ognl.allowStaticMethodAccess" value="true" /> <constant name="struts.objectFactory" value="spring" /> <!--web.xml中限定.jsp,.do后缀的请求转发给struts。这里添加以保持一致,正常接受--> <constant name="struts.action.extension" value="do" /> <!-- 全局变量 --> <package name="global" namespace="/" extends="struts-default"> <global-results> <result name="error">/WEB-INF/pages/error.jsp</result> <result name="index">/index.jsp</result> <result name="adminLogin">/admin/login.jsp</result> </global-results> <global-exception-mappings> <exception-mapping result="error" exception="Exception"></exception-mapping> </global-exception-mappings> </package> <package name="ajax" namespace="/ajax" extends="global"> <!--class是从spring容器中取出的bean,所以是Bean的名字--> <action name="fileupload" class="fileuploadAction"> <result>/WEB-INF/uploadsuccess.jsp</result> </action> </package> </struts>
本例也加入了fckeditor,web.xml也有监听fckeditor类,所以也给出fckeditor.properties, (项目src的目录下)
connector.userActionImpl=net.fckeditor.requestcycle.impl.EnabledUserAction