CMS是”Content Management System”的缩写,意为”内容管理系统”。 内容管理系统是企业信息化建设和电子政务的新宠,也是一个相对较新的市场。对于内容管理,业界还没有一个统一的定义,不同的机构有不同的理解。
· 基于java技术开发,继承其强大、稳定、安全、高效、跨平台等多方面的优点
· 采用SpringMVC3+Spring3+Hibernate3+Freemarker主流技术架构
· 懂html就能建站,提供最便利、合理的使用方式
· 强大、灵活的标签,用户自定义显示内容和显示方式
· 在设计上自身预先做了搜索引擎优化,增强对搜索引擎的友好性
· 完全生成全站静态页面,可自定义路径结构,全面提高页面访问速度
· 轻松建设大规模网站,可通过次级域名建立子站群,各子站后台管理权限分离,全站实现单点登录
jeeCms源码安装时出现的问题及解决
装MySQL数据库装不上
因为以前本机上装过MySQL,而在卸载时有文件残留,故MySQL会安装失败,失败的表现有两种:一个是安装时未响应,一个是未弹出配置MySQL的界面。
解决办法:
- 你可以安装MySQL的时候在这一步时它默认的服务名是“MySQL” 只需要把这个名字改了就可以了。
-
数据库连接不上的问题
错误提示: An attempt by a client to checkout a Connection has timed out.
原因:
解决办法:删除除mysql安装残留信息时一定要谨慎再谨慎
src包中报错的问题:
错误提示:所有带HttpServletRequest或HttpServletResponse的类全部显示错误
原因:没有找到servlet包。因为你安装源码包时,没有配置tomcat环境。
解决办法:
安装源码包时,先在eclipse中配置tomcat环境,再建动态web项目,然后再在web项目中覆盖src和webContent文件夹。
源码解析之一 (web.xml)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
| <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>JeeCmsV7</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/config/application-context.xml /WEB-INF/config/cache-context.xml /WEB-INF/config/captcha-context.xml /WEB-INF/config/jeecms/jeecore-context.xml /WEB-INF/config/jeecms/jeecms-context.xml /WEB-INF/config/shiro-context.xml /WEB-INF/config/plug/**/*-context.xml /WEB-INF/config/quartz-task.xml </param-value> </context-param> <filter> <filter-name>processTime</filter-name> <filter-class>com.jeecms.common.web.ProcessTimeFilter</filter-class> </filter> <filter> <filter-name>encoding</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter> <filter-name>osivFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter> <filter-name>XssFilter</filter-name> <filter-class>com.jeecms.common.web.XssFilter</filter-class> <init-param> <param-name>excludeUrls</param-name> <param-value>/member/contribute@/jeeadmin/jeecms@/flow_statistic</param-value> </init-param> <init-param> <param-name>SplitChar</param-name> <param-value>@</param-value> </init-param> <init-param> <param-name>FilterChar</param-name> <param-value>'@"@\@#@:@%@></param-value> </init-param> <init-param> <param-name>ReplaceChar</param-name> <param-value>‘@“@\@#@:@%@></param-value> </init-param> </filter> <filter-mapping> <filter-name>processTime</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <filter-mapping> <filter-name>osivFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <filter-mapping> <filter-name>processTime</filter-name> <url-pattern>*.jspx</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>*.jspx</url-pattern> </filter-mapping> <filter-mapping> <filter-name>osivFilter</filter-name> <url-pattern>*.jspx</url-pattern> </filter-mapping> <filter-mapping> <filter-name>processTime</filter-name> <url-pattern>*.jhtml</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>*.jhtml</url-pattern> </filter-mapping> <filter-mapping> <filter-name>osivFilter</filter-name> <url-pattern>*.jhtml</url-pattern> </filter-mapping> <filter-mapping> <filter-name>processTime</filter-name> <url-pattern>*.htm</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>*.htm</url-pattern> </filter-mapping> <filter-mapping> <filter-name>osivFilter</filter-name> <url-pattern>*.htm</url-pattern> </filter-mapping> <filter-mapping> <filter-name>processTime</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>osivFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>osivFilter</filter-name> <url-pattern>/</url-pattern> </filter-mapping> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>XssFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
<servlet> <servlet-name>JeeCmsAdmin</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/config/jeecms-servlet-admin.xml /WEB-INF/config/plug/**/*-servlet-admin-action.xml </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>JeeCmsFront</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/config/jeecms-servlet-front.xml /WEB-INF/config/plug/**/*-servlet-front-action.xml </param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <servlet> <servlet-name>Jcaptcha</servlet-name> <servlet-class>com.jeecms.common.captcha.JcaptchaServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Jcaptcha</servlet-name> <url-pattern>/captcha.svl</url-pattern> </servlet-mapping> <servlet> <servlet-name>DbFile</servlet-name> <servlet-class>com.jeecms.core.action.front.DbFileServlet</servlet-class> </servlet> <servlet> <servlet-name>SnapScreen</servlet-name> <servlet-class>com.jeecms.core.action.front.SnapScreenServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>SnapScreen</servlet-name> <url-pattern>/snapscreen.svl</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>JeeCmsAdmin</servlet-name> <url-pattern>/jeeadmin/jeecms/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>JeeCmsFront</servlet-name> <url-pattern>*.jhtml</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>JeeCmsFront</servlet-name> <url-pattern>*.jspx</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>JeeCmsFront</servlet-name> <url-pattern>*.jsp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>JeeCmsFront</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>DbFile</servlet-name> <url-pattern>/dbfile.svl</url-pattern> </servlet-mapping>
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
<listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <session-config> <session-timeout>20</session-timeout> </session-config> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.shtml</welcome-file> <welcome-file>index.jhtml</welcome-file> </welcome-file-list> <error-page> <error-code>403</error-code> <location>/WEB-INF/error/403.html</location> </error-page> <error-page> <error-code>404</error-code> <location>/404.html</location> </error-page> <error-page> <error-code>500</error-code> <location>/WEB-INF/error/500.html</location> </error-page> <mime-mapping> <extension>rar</extension> <mime-type>application/zip</mime-type> </mime-mapping> <mime-mapping> <extension>doc</extension> <mime-type>application/zip</mime-type> </mime-mapping> <mime-mapping> <extension>wps</extension> <mime-type>application/zip</mime-type> </mime-mapping> <mime-mapping> <extension>et</extension> <mime-type>application/zip</mime-type> </mime-mapping> </web-app>
|
源码解析之二(application-context.xml)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
| <?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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd" default-lazy-init="true">
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>/WEB-INF/config/jdbc.properties</value> </list> </property> </bean> <bean id="properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="locations"> <list> <value>/WEB-INF/config/jdbc.properties</value> <value>/WEB-INF/config/jeecms/jeecms.properties</value> <value>/WEB-INF/config/plug/**/*.properties</value> </list> </property> <qualifier value="main"/> </bean> <bean id="propertyUtils" class="com.jeecms.common.util.PropertyUtils"> <property name="properties" ref="properties"/> </bean> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driverClassName}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="user" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="autoCommitOnClose" value="true"/> <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/> <property name="initialPoolSize" value="${cpool.minPoolSize}"/> <property name="minPoolSize" value="${cpool.minPoolSize}"/> <property name="maxPoolSize" value="${cpool.maxPoolSize}"/> <property name="maxIdleTime" value="${cpool.maxIdleTime}"/> <property name="acquireIncrement" value="${cpool.acquireIncrement}"/>
<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mappingLocations" value="#{propertyUtils.getList('hibernate.hbm')}"/> <property name="hibernateProperties"> <value> hibernate.dialect=${hibernate.dialect} hibernate.show_sql=false hibernate.format_sql=false
hibernate.query.substitutions=true 1, false 0 hibernate.jdbc.batch_size=20
hibernate.cache.use_query_cache=true </value> </property> <property name="entityInterceptor"> <ref local="treeInterceptor"/> </property> <property name="cacheProvider"> <ref local="cacheProvider"/> </property> <property name="lobHandler"> <ref bean="lobHandler" /> </property> </bean> <bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/> <bean id="cacheProvider" class="com.jeecms.common.hibernate3.SpringEhCacheProvider"> <property name="configLocation"> <value>/WEB-INF/config/ehcache-hibernate.xml</value> </property> <property name="diskStoreLocation"> <value>/WEB-INF/cache/hibernate</value> </property> </bean> <bean id="treeInterceptor" class="com.jeecms.common.hibernate3.TreeIntercptor"/> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <context:annotation-config/> <tx:annotation-driven transaction-manager="transactionManager" /> </beans>
|
源码解析之三(ehcache-hibernate.xml)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
<?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
<defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" diskSpoolBufferSizeMB="30" maxElementsOnDisk="10000000" diskPersistent="false" diskExpiryThreadIntervalSeconds="120" /> <cache name="org.hibernate.cache.StandardQueryCache" maxElementsInMemory="50" eternal="false" timeToIdleSeconds="3600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="org.hibernate.cache.UpdateTimestampsCache" maxElementsInMemory="5000" eternal="true" overflowToDisk="true" />
<cache name="com.jeecms.core.entity.Sys" maxElementsInMemory="20" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.core.entity.DbTpl" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.core.entity.Ftp" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" />
<cache name="com.jeecms.cms.entity.main.ContentExt" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Content" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.ContentType" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsUserSite" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsUserExt" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.ChannelTxt" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.ContentTag" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsUser" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.ContentTxt" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Channel" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsRole" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsModel" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsGroup" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.ContentCount" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsSite" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsSiteCompany" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.ChannelExt" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.ContentCheck" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsConfig" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Channel.viewGroups" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsSite.attr" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Content.attr" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsGroup.contriChannels" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsRole.perms" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsUser.channels" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Content.pictures" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsSite.txt" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Channel.child" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsSite.cfg" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Content.contentCheckSet" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Channel.users" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsUser.userExtSet" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Channel.attr" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Content.attachments" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsGroup.viewChannels" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Channel.contriGroups" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Content.viewGroups" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Content.tags" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.CmsConfig.attr" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Content.contentTxtSet" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.main.Channel.channelTxtSet" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" />
<cache name="com.jeecms.cms.entity.assist.CmsVoteTopic.items" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.assist.CmsKeyword" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.assist.CmsCommentExt" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.assist.CmsGuestbookExt" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.assist.CmsSensitivity" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.assist.CmsVoteTopic" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.assist.CmsGuestbookCtg" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.assist.CmsVoteRecord" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.assist.CmsVoteItem" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.assist.CmsGuestbook" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.assist.CmsComment" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" /> <cache name="com.jeecms.cms.entity.assist.CmsJobApply" maxElementsInMemory="100" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="7200" overflowToDisk="true" />
|
源码解析之四(cache-context.xml)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
| <pre name="code" class="java"><?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd" default-lazy-init="true"> <bean id="cacheManager" class="com.jeecms.common.web.WebEhCacheManagerFacotryBean"> <property name="configLocation"> <value>/WEB-INF/config/ehcache-application.xml</value> </property> <property name="diskStoreLocation"> <value>/WEB-INF/cache/application</value> </property> </bean> <bean id="ehSessionCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref local="cacheManager"/> </property> <property name="cacheName"> <value>com.jeecms.common.web.Session</value> </property> <qualifier value="session"/> </bean> <bean id="ehContentCountCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref local="cacheManager"/> </property> <property name="cacheName"> <value>com.jeecms.cms.front.ContentCount</value> </property> <qualifier value="contentCount"/> </bean> <bean id="ehChannelCountCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref local="cacheManager"/> </property> <property name="cacheName"> <value>com.jeecms.cms.front.ChannelCount</value> </property> <qualifier value="channelCount"/> </bean> <bean id="ehWeixinTokenCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref local="cacheManager"/> </property> <property name="cacheName"> <value>com.jeecms.cms.weixin.token</value> </property> <qualifier value="tokenCache"/> </bean> <bean id="ehCmsSiteFlowCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref local="cacheManager"/> </property> <property name="cacheName"> <value>com.jeecms.cms.front.CmsSiteFlow</value> </property> <qualifier value="cmsSiteFlow"/> </bean> <bean id="ehCmsSiteAccessCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref local="cacheManager"/> </property> <property name="cacheName"> <value>com.jeecms.cms.front.CmsAccess</value> </property> <qualifier value="cmsAccessCache"/> </bean> <bean id="ehCmsSiteLastAccessCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref local="cacheManager"/> </property> <property name="cacheName"> <value>com.jeecms.cms.front.CmsLastAccess</value> </property> <qualifier value="cmsLastAccessCache"/> </bean> <bean id="ehCmsSiteAccessPagesCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref local="cacheManager"/> </property> <property name="cacheName"> <value>com.jeecms.cms.front.CmsAccessPage</value> </property> <qualifier value="cmsAccessPageCache"/> </bean> <bean id="ehPvTotalCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref local="cacheManager"/> </property> <property name="cacheName"> <value>com.jeecms.cms.front.CmsSitePvTotal</value> </property> <qualifier value="cmsPvTotalCache"/> </bean> <bean id="ehVisitorTotalCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref local="cacheManager"/> </property> <property name="cacheName"> <value>com.jeecms.cms.front.CmsSiteVisitorTotal</value> </property> <qualifier value="cmsVisitorTotalCache"/> </bean> <bean id="ehSearchWordsCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref local="cacheManager"/> </property> <property name="cacheName"> <value>com.jeecms.cms.front.CmsSearchWords</value> </property> <qualifier value="cmsSearchWords"/> </bean>
</beans>
|
源码解析之五(Spring + FreeMarker的集成)
共四步
加载属性文件 application-context.xml下的jeecms.properties,会在第四步用到。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>JeeCmsV7</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/config/application-context.xml /WEB-INF/config/cache-context.xml /WEB-INF/config/captcha-context.xml /WEB-INF/config/jeecms/jeecore-context.xml /WEB-INF/config/jeecms/jeecms-context.xml /WEB-INF/config/shiro-context.xml /WEB-INF/config/plug/**/*-context.xml /WEB-INF/config/quartz-task.xml </param-value> </context-param> ... </web-app>
|
前台配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="freemarkerVariables" value="#{propertyUtils.getBeanMap('directive.')}"/> <property name="templateLoaderPath" value=""/> <property name="freemarkerSettings"> <props> <prop key="tag_syntax">auto_detect</prop> <prop key="template_update_delay">5</prop> <prop key="defaultEncoding">UTF-8</prop> <prop key="url_escaping_charset">UTF-8</prop> <prop key="locale">zh_CN</prop> <prop key="boolean_format">true,false</prop> <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop> <prop key="date_format">yyyy-MM-dd</prop> <prop key="time_format">HH:mm:ss</prop> <prop key="number_format">0.######</prop> <prop key="whitespace_stripping">true</prop> <prop key="auto_import">/WEB-INF/ftl/jeecms/index.ftl as p,/WEB-INF/ftl/spring.ftl as s</prop> </props> </property> </bean>
|
解析 FreeMarker 视图
1 2 3 4 5 6 7 8 9 10
| <bean id="freemarkerViewResolver" class="com.jeecms.common.web.springmvc.SimpleFreeMarkerViewResolver"> <property name="contentType" value="text/html; charset=UTF-8"/> <property name="exposeRequestAttributes" value="false"/> <property name="exposeSessionAttributes" value="false"/> <property name="exposeSpringMacroHelpers" value="true"/> </bean>
|
后台配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="templateLoaderPath" value="/WEB-INF"/> <property name="freemarkerVariables"> <map> <entry key="appBase" value="/jeeadmin/jeecms"/> <entry key="cms_perm" value-ref="cms_perm"/> <entry key="text_cut" value-ref="text_cut"/> <entry key="html_cut" value-ref="html_cut"/> <entry key="cms_content_list" value-ref="cms_content_list"/> <entry key="cms_content_page" value-ref="cms_content_page"/> </map> </property> <property name="freemarkerSettings"> <props> <prop key="template_update_delay">0</prop> <prop key="defaultEncoding">UTF-8</prop> <prop key="url_escaping_charset">UTF-8</prop> <prop key="locale">zh_CN</prop> <prop key="boolean_format">true,false</prop> <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop> <prop key="date_format">yyyy-MM-dd</prop> <prop key="time_format">HH:mm:ss</prop> <prop key="number_format">0.######</prop> <prop key="whitespace_stripping">true</prop> <prop key="auto_import">/ftl/jeecms/index.ftl as p,/ftl/spring.ftl as s</prop> </props> </property> </bean>
|
解析 FreeMarker 视图
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <bean id="freemarkerViewResolver" class="com.jeecms.common.web.springmvc.RichFreeMarkerViewResolver"> <property name="prefix" value="/jeecms_sys/"/> <property name="suffix" value=".html"/> <property name="contentType" value="text/html; charset=UTF-8"/> <property name="exposeRequestAttributes" value="false"/> <property name="exposeSessionAttributes" value="false"/> <property name="exposeSpringMacroHelpers" value="true"/> </bean>
|
注入freeMarkerConfigurer(jeecms-context.xml)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| <bean id="staticPageSvc" class="com.jeecms.cms.staticpage.StaticPageSvcImpl"> <property name="tplMessageSource" ref="tplMessageSource"/> <property name="freeMarkerConfigurer"> <bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="freemarkerVariables" value="#{propertyUtils.getBeanMap('directive.')}"/> <property name="templateLoaderPath" value=""/> <property name="freemarkerSettings"> <props> <prop key="tag_syntax">auto_detect</prop> <prop key="template_update_delay">5</prop> <prop key="defaultEncoding">UTF-8</prop> <prop key="url_escaping_charset">UTF-8</prop> <prop key="locale">zh_CN</prop> <prop key="boolean_format">true,false</prop> <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop> <prop key="date_format">yyyy-MM-dd</prop> <prop key="time_format">HH:mm:ss</prop> <prop key="number_format">0.######</prop> <prop key="whitespace_stripping">true</prop> <prop key="auto_import">/WEB-INF/ftl/jeecms/index.ftl as p,/WEB-INF/ftl/spring.ftl as s</prop> </props> </property> </bean> </property> </bean>
|
源码解析之六(前台页面初始化)
项目启动,初始化配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/config/application-context.xml /WEB-INF/config/cache-context.xml /WEB-INF/config/captcha-context.xml /WEB-INF/config/jeecms/jeecore-context.xml /WEB-INF/config/jeecms/jeecms-context.xml /WEB-INF/config/shiro-context.xml /WEB-INF/config/plug/**/*-context.xml /WEB-INF/config/quartz-task.xml </param-value> </context-param>
|
1
| <bean id="dynamicAct" class="com.jeecms.cms.action.front.DynamicPageAct"/>
|
通过过滤器进入
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
@RequestMapping(value = "/", method = RequestMethod.GET) public String index(HttpServletRequest request,HttpServletResponse response, ModelMap model) { CmsSite site = CmsUtils.getSite(request); FrontUtils.frontData(request, model, site); String uri=URLHelper.getURI(request); if(StringUtils.isNotBlank(uri)&&!uri.equals("/")){ return FrontUtils.pageNotFound(request, response, model); } if(site.getStaticIndex()&&new File(realPathResolver.get(site.getStaticDir()+INDEX)).exists()){ return FrontUtils.getTplPath("", site.getStaticDir(), INDEX); }else{ return site.getTplIndexOrDef(); } }
|
返回一个url并 进入主页。
1 2 3 4 5 6
| <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.shtml</welcome-file> <welcome-file>index.jhtml</welcome-file> </welcome-file-list>
|
通过标签进入指定的类,并调用期execute()方法(以前台@cms_content_list为例)
前台标签:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <div class="cl"> <ul class="slideshow" id="slidesImgs"> [@<strong>cms_content_list</strong> count='5' orderBy='4' typeId='3' titLen='18' channelOption='1' channelId='1'] [#list tag_list as a] <li> <a href="${a.url}" target="_blank"> <img src="${a.typeImg!site.defImg}" alt="${a.title}" width="100%" /> </a> <span class="title"> [@text_cut s=a.title len=titLen /] </span> </li> [/#list] [/@cms_content_list] </ul> </div>
|
在web.xml—>jeecms-contextxml 配置中找到相关的处理类
1
| <bean id="cms_content_list" class="com.jeecms.cms.action.directive.ContentListDirective"/>
|
调用其execute()方法对其进行处理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
public static final String TPL_NAME = "content_list";
public static final String PARAM_IDS = "ids"; @SuppressWarnings("unchecked") public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { CmsSite site = FrontUtils.getSite(env); List<Content> list = getList(params, env); Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(params); paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(list)); Map<String, TemplateModel> origMap = DirectiveUtils.addParamsToVariable(env, paramWrap); InvokeType type = DirectiveUtils.getInvokeType(params); String listStyle = DirectiveUtils.getString(PARAM_STYLE_LIST, params); if (InvokeType.sysDefined == type) { if (StringUtils.isBlank(listStyle)) { throw new ParamsRequiredException(PARAM_STYLE_LIST); } env.include(TPL_STYLE_LIST + listStyle + TPL_SUFFIX, UTF8, true); } else if (InvokeType.userDefined == type) { if (StringUtils.isBlank(listStyle)) { throw new ParamsRequiredException(PARAM_STYLE_LIST); } FrontUtils.includeTpl(TPL_STYLE_LIST, site, env); } else if (InvokeType.custom == type) { FrontUtils.includeTpl(TPL_NAME, site, params, env); } else if (InvokeType.body == type) { body.render(env.getOut()); } else { throw new RuntimeException("invoke type not handled: " + type); } DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); } @SuppressWarnings("unchecked") protected List<Content> getList(Map<String, TemplateModel> params, Environment env) throws TemplateException { Integer[] ids = DirectiveUtils.getIntArray(PARAM_IDS, params); if (ids != ) { return contentMng.getListByIdsForTag(ids, getOrderBy(params)); } else { return (List<Content>) super.getData(params, env); } }
|
前台通过标签循环取出数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <ul class="slideshow" id="slidesImgs"> [@cms_content_list count='5' orderBy='4' typeId='3' titLen='18' channelOption='1' channelId='1'] [#list tag_list as a] <li> <a href="${a.url}" target="_blank"> <img src="${a.typeImg!site.defImg}" alt="${a.title}" width="100%" /> </a> <span class="title"> [@text_cut s=a.title len=titLen /] </span> </li> [/#list] [/@cms_content_list] </ul>
|
源码解析之七(前台页面初始化是request赋值)
问题:
当输入http://localhost:8070/jeeCms/时,通过拦截器“/”后台时,request 中包含了很多值是哪里来的?
回答:
加载web.xml
1 2 3 4 5 6 7 8 9 10 11 12 13
| <servlet> <servlet-name>JeeCmsFront</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/config/jeecms-servlet-front.xml /WEB-INF/config/plug/**/*-servlet-front-action.xml </param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet>
|
其初使化方法中 进入jeecms-servlet-front.xml,初使化:
1
| <bean id="frontContextInterceptor" class="com.jeecms.cms.web.FrontContextInterceptor"/>
|
为reques和中放入值
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
public class FrontContextInterceptor extends HandlerInterceptorAdapter { public static final String SITE_COOKIE = "_site_id_cookie"; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException { CmsSite site = ; List<CmsSite> list = cmsSiteMng.getListFromCache(); int size = list.size(); if (size == 0) { throw new RuntimeException("no site record in database!"); } else if (size == 1) { site = list.get(0); } else { String server = request.getServerName(); String alias, redirect; for (CmsSite s : list) { if (s.getDomain().equals(server)) { site = s; break; } alias = s.getDomainAlias(); if (!StringUtils.isBlank(alias)) { for (String a : StringUtils.split(alias, ',')) { if (a.equals(server)) { site = s; break; } } } redirect = s.getDomainRedirect(); if (!StringUtils.isBlank(redirect)) { for (String r : StringUtils.split(redirect, ',')) { if (r.equals(server)) { try { response.sendRedirect(s.getUrl()); } catch (IOException e) { throw new RuntimeException(e); } return false; } } } } if (site == ) { throw new SiteNotFoundException(server); } } <span style="background-color: rgb(204, 153, 51);">CmsUtils.setSite(request, site);</span> CmsThreadVariable.setSite(site); Subject subject = SecurityUtils.getSubject(); if (subject.isAuthenticated()|| subject.isRemembered()) { String username = (String) subject.getPrincipal(); CmsUser user = cmsUserMng.findByUsername(username); CmsUtils.setUser(request, user); CmsThreadVariable.setUser(user); } createJsessionId(request, response, site); return true; }
|
源码解析之八(jeeCms整合webservice)
第一步:在jeeCms .添加jar包
第二步:增加webservice相关配置。
web.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/config/application-context.xml /WEB-INF/config/cache-context.xml /WEB-INF/config/captcha-context.xml /WEB-INF/config/jeecms/jeecore-context.xml /WEB-INF/config/jeecms/jeecms-context.xml /WEB-INF/config/shiro-context.xml /WEB-INF/config/plug/**/*-context.xml /WEB-INF/config/quartz-task.xml <span style="color:#ff6666;"> /WEB-INF/config/webservice/cxf-service.xml</span> </param-value> </context-param>
|
1 2 3 4 5 6 7 8 9 10
| <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/ws/*</url-pattern> </servlet-mapping>
|
cxf-service.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| <?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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd"> <http-conf:conduit name="*.http-conduit"> <http-conf:client ConnectionTimeout="60000" ReceiveTimeout="60000"/> </http-conf:conduit> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <import resource="action-cxf.xml" /> </beans>
|
action-cxf.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <?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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
</beans>
|
第三步 创建webService 接口类,用来存放调用webService 的方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| package com.jeecms.cms.action.directive; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; @WebService(targetNamespace="http://webservice.cus.biz.cbp.cj.com/") public interface countInfoInterfaceNpl { public static final String SERVICE_NAME = "FindAllCustWebSerrvice";
@WebMethod String findByIdCustB(@WebParam(name = "partnerId") String partnerId, @WebParam(name = "traT") String traT, @WebParam(name = "custB") String custB, @WebParam(name = "orderId") String orderId,@WebParam(name = "verifyCode") String verifyCode); }
|
第四步 java类中调用webservice
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| package com.jeecms.cms.action.directive; import static com.jeecms.common.web.freemarker.DirectiveUtils.OUT_BEAN; import static freemarker.template.ObjectWrapper.DEFAULT_WRAPPER; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; import javax.jws.WebService; import org.apache.cxf.interceptor.LoggingInInterceptor; import org.apache.cxf.interceptor.LoggingOutInterceptor; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import com.jeecms.common.web.freemarker.DirectiveUtils; import freemarker.core.Environment; import freemarker.template.TemplateDirectiveBody; import freemarker.template.TemplateDirectiveModel; import freemarker.template.TemplateException; import freemarker.template.TemplateModel;
public class CountInfoNpl implements TemplateDirectiveModel { @SuppressWarnings("unchecked") public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { try { int i=1; if(i==1){ JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getInInterceptors().add(new LoggingInInterceptor()); factory.getOutInterceptors().add(new LoggingOutInterceptor()); factory.setServiceClass(countInfoInterfaceNpl.class); factory.setAddress("http://127.0.0.1:8060/ws/FindAllCustWebSerrvice"); Object cInstance = factory.create(); Method invokeMethod = ; for(Method m : (countInfoInterfaceNpl.class).getDeclaredMethods()){ if(!m.getName().equalsIgnoreCase("")){ invokeMethod = m; break; } } if(invokeMethod == ) throw new Exception("ERROR:method not found"); Object[] params1 = new Object[5]; params1[0] = ; params1[1] = "aaaa"; params1[2] = "bbnn"; params1[3] = ; params1[4] = ; CustBNpl res = (CustBNpl) invokeMethod.invoke(cInstance, params1); System.out.println("aaa"); }else{ Map<String,String> cmsVoteInfo=new HashMap<String,String>(); cmsVoteInfo.put("publicInfo", "加薪宝涨息"); cmsVoteInfo.put("totalCaptial","20000001"); cmsVoteInfo.put("goldCaptial","5555555"); cmsVoteInfo.put("getMoney","6666666"); Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>( params); paramWrap.put(OUT_BEAN, DEFAULT_WRAPPER.wrap(cmsVoteInfo)); Map<String, TemplateModel> origMap = DirectiveUtils.addParamsToVariable(env, paramWrap); body.render(env.getOut()); DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); } } catch (Exception e) { e.printStackTrace(); } } }
|