webgis系统实现

开发环境搭建

城市地下电力管线管理系统是基于B/ S 架构的应用管理系统,其系统开发平台的软件
环境配置要求如下:
(1)操作系统: Windows 系列。
(2) Java 运行环境: JDK 1. 6 及以上版本。
(3) Web 服务器: Tomcat 7. 0 服务器。
(4)数据库: PostgreSQL 9. 2 和PostGIS 2. 0 及以上版本。
(5)地图服务器: GeoServer 2. 3 及以上版本。
(6) J2EE 开发平台使用: Eclipse 4.2 及以上版本。系统在Eclipse 平台下使用Java 、HTML 和JavaScript 等语言进行J2EE 开发。系统的开发平台使用开源的GIS 框架: GeoServer 、PostGIS 和OpenLayers 。GeoServer 是系统的GIS 服务器,主要作为GIS 服务的发布平台; PostGIS 为系统空间数据的存储提供支持;
OpenLayers 为网页端的GIS 开发框架,能够快速进行网页端GIS 功能的开发和维护。
(1)项目开发的第一步是搭建项目环境及项目集成框架等,在此之前需要将Spring2 、Structs2 、Hibernate 及系统应用的其他jar 包导人到项目的lib 文件下。
接下来需要对Struts 、Spring 、Hibernate 以及web. xml 文件进行配置。这些配置文件
的配置过程如下。
(2)配置Struts2 :在项目的ClassPath 下创建Struts. xml 文件,其配置代码如下。

<?xrnlversion =1. 0 ” encoding = ” UTF - 8?>
<!OOCTYPEstrutsPUBLIC
~//ApacheSoftwareFoundation//DTD StrutsConfiguration2 . 。//四”
” http: I I struts. apache. org/ dtd s/ struts - 2. 0. dtd ”>
<struts>
< constant name = ” struts. devMode” value= "false/>
< constant name =” struts.multipart.saveDir” value =/tmp"></constant >
< constant name =” struts . multipart.maxSize” value =20971520/>
〈! 一树目录及侧栏配置一〉
< package name =” tree" extends =”struts - default>
< action name =” initTree” class =” treeAction” method z ” execute”>
< result name = "error”>/ wrong. jsp </result>
</action>
<action n臼ne =”getSideBarJson” class =” getSideBarJson ”『『teth od =”execute”>
< result name =飞rror ”>/ wrong . jsp</result>
</action>
< action name =”getSideBarJJson” class =”getSideBarJJson” method =” execute ”>
< result name =” error”>/wrong. jsp</result>
</action>
</package>
〈! -- 地图相关配置-一〉
< package name =” property” extends =”struts - default>
< interceptors >
< interceptor name =” loginCheck'’ class =” loginChecl♂〉
</interceptor >
< interceptor - stackname =”myStack”>
< interceptor - ref name =” loginCheck"/>
< interceptor - ref name = "defaul tStack”/>
</interceptor - stack>
</interceptors >
<default - interceptor - refname = "myStack”></default - interceptor - ref>
< global - results >
< result name =”unlogin ”>/ template/relogin. jsp </result>
</global - results >
<action n田ne =”getProperty” class =”getProperty” method =” execute”>
<result n四e =” 1010203 ”>/ template/property/ transformer. j sp </result>
··.〈!省略的配置信息〉
</action>
< action name =” getPropertyJson” class =” getPropertyJson” method =” execute”>
< result name =” input">/ template/ common/ error. jsp </result >
</action>
< action name =”getPropertiesJson” class =”getPropertiesJson”
method =” execute”>
< result name =” input”>/template/common/error . jsp </result>
</action>
</package>
〈!--系统功能配置--〉
<package n出ne =”system” extends =” struts - default>
< interceptors >
< interceptor n副ne =”loginCheck” class =” loginCheck”>
</interceptor >
</interceptors >
<global - results>
< result name =”unlogin”>/template/relogin. jsp </result>
</global - results>
<action n副ne = ” home" class =” home " method =”execute”>
<result n四e =” success”>/ template/home. jsp </result>
<result 旦出e =” unl 吨川、/template/login. jsp </result>
< interceptor - ref name =” defaultStack”/>
< interceptor - refname =” loginCheck”/>
</action>
〈!省略的配置信息〉
</package>
</struts>

配置Hibernate

: 在Hibernate 的配置文件中配置数据库的连接信息、数据库方言
及打印SQL 语句等属性,其关键代码如下。

<?xmlversion =” 1. 。” encoding =” utf- 8?>
<! OOCTYPEhibernate - configurationPUBLIC
”- I /Hibernate/HibernateConf igurationDTD 3. O I /EN”
” http: //www.hibernate.org/dtd /hibernate configuration- 3 . 0 . dtd ”>
<hibernate - configuration>
<session - factory>
<property nne =”hibernate.bytecode.use_reflection_optimizer”> false
</property >
<property nne =”hibernate . connection. driver_class”>
org. postgresql. Driver</ property>
< property name =”hibernate. connection. password "> admin </property>
< property name =” hibernate.connection.url”>
jdbc: postgresql: //localhost : 5432/0pengisData Base </property>
< property name =” hibernate.connection.usern四e ”> postgres </property>
<property nne =”hibernate.dialect”>
org. hibernate. spatial. dialect. postgis. PostgisDialec t </property>
< property name =” hibernate. format sql ”> true </property >
<property nne =” hibernate. search.autoregister_ listeners ”> false
</property>
< property name =飞ibernate. show_sql ”> true </property>
< property name =” hibernate.connection.pool_size”> 20 </property>
<property n皿e =” hibernate. proxool. pool_alias 与pooll </property>
< property name =” hibernate.max_fetch_depth ”> 1 </property>
< property name =”hibernate. jdbc.batch versioned_data”> true </property >
<property n四e =” hibernate . jdbc . use_streams for binary”> true </property >
<property n四e =” hibernate.cache . region_prefix”> hibernate. test </property>
<property n副ne =”hibernate.cache . provider_class ”>
org. hibernate. cache. Hashtable CacheProv ider </property>
< mapping resource =”org/resource/object/PdEwPpBuried.hbm. xml ”/>
.... <!省略的映射信息〉
</session - factory>
</hibernate - configuration>

配置Spring :利用Spring 加载Hibernate 的配置文件及Session 管理类,在配置
Spring 时只需要配置Spring 的核心配置文件applicationContex. xml ,其代码如下。

<?xmlversion =” 1. 。” encoding =” UTF- 8?>
< beansxmlns =” http : //阳w springframework. 口rg/sch四a/beans"
xmlns:xsi =” http: //www.w3.org/2001/XMLSchema- instance"
xmlns:aop =”http : //www.springframework.org/schema/aop”
xmlns :tx =飞ttp://www.springframework.org/schema/tx ”
xsi: schemaLocation =” http : //www. springframework. org/schema/beanshttp://www.
springframework. org/schema/beans/spring - beans - 2 . 5. xsdhttp://www. springframework. org/
schema/ aophttp: I I www. springframework. org/ schema/ aop/ spring - aop - 2 . 5. xsdhttp: I I www.
springframework. org/ schema/txhttp : I /www. springframework. org/ sch四a/tx/ spring - tx - 2 . 5.
xsd”>
〈! 一Service 服务层配置
######################################-->
〈! 一树目录一〉
<bean name =” treeService" class =”。rg . ldw.service.treeService">
< property name =” treeDao”>
<ref bean =” treeDa。”/〉
</property>
</bean>
〈!--登录一- 〉
<bean n四e =” loginService” class =” org. ldw.service.loginService”>
< property name =” userDa。”〉
<ref bean =” systemUser”/>
</property>
</bean>
<I --属性--〉
<bean name =”propertyService” class =”org.ldw.service.propertyService”>
<property name =”daoSelect”>
<ref bean =” selectRecordAll ”/>
</property>
<property n缸ne =” daoSave”>
<ref bean =电aveProperty”/〉
</property>
</bean>
〈!--系统用户管理--〉
<bean n四e =” systemUserService ” class =” org. ldw. service. systemUserService、
<property n缸ne = ” userDa。”〉
<ref bean =飞ystemUser ”/〉
</property>
</be皿〉
〈!一文件数据导人一〉
<bean name =import ExcelServiceclass =”org. ldw. service. import
Excel Service” scope =”prototype”>
< property name =import Da。”〉
<ref bean =import Da。”/〉
</property>
<property n缸ne =import DaoEle>
<ref bean =import DaoEle/>
</property >
<property n缸ne =import DaoWirecable>
<ref bean =import DaoWirecable/>
</property>
<property n四e =” import DaoObj ">
<ref bean =import DaoObj/>
</property>
</be四〉
〈!一一图片导人--〉
<bean name =飞ploadsPhotoService"
class =” org.ldw. service.uploadsPhotoService” scope =”prototype”>
<property name= "jpegTool ">
<ref bean =” jpegTool”/>
</property>
<property name =” daoSave”>
<ref bean =SaveProperty/>
</property>
< property name =”photo”>
<ref bean =” photo”/>
</property >
</bean>
<!一拦截器一〉
<bean n四e =” loginCheck ” class =飞rg. ldw.action. logininterceptor”/>
<! -- Action 视图层配置
######################################-->
<bean name =” home" class =” org.ldw.action . homeAction”/>
<bean n副ne =” login” class =” org.ldw.action. login且ct ion” scope =”prototype">
<property n缸ne =” loginService”>
<ref bean =” loginService”/>
</property>
</bean>
</servlet>
< serv let - mapping>
< servlet - name> default </servlet - name>
< url - pattern >/</url - pattern>
</ servlet - mapping>
< servlet - mapping>
< servlet - name> cgi </ servlet - name>
< url - pattern >/cgi /祷</url - pattern>
</servlet - mapping>
〈! 一strut2 的配置一- 〉
<session - config >
<session - timeout> 3600 </session - timeout>
</session - c口nfig>
<filter>
< filter - name> struts2 </filter - name>
<filter - class>7章城市地下电力管线GIS 系统|’ 297
org. apache. struts2.dispatcher. ng. filter . StrutsPrepareAndExecuteFilter
</filter - class>
</filter>
< filter - mapping>
< filter - name> struts2 </filter - name>
< url - pattern > 替. action</ url - pattern>
< dispatcher >阻QUEST</ dispatcher>
< dispatcher> FORWARD</ dispatcher>
</filter - mapping>
< filter - mapping>
< filter - name> struts2 </ filter - name>
< ur 1 - pattern >普. jsp </url - pattern>
< dispatcher> REQUEST</ dispatcher>
< dispatcher> FORWARD</ dispatcher>
</filter - mapping>
〈! 一spring 监听- -〉
<listener>
< listener - class >
org.springframework.web.context.ContextLoaderListener
</listener - class>
</listener>
</web - app>

配置完以上文件,整个项目的框架就搭建好了

猜你喜欢

转载自blog.csdn.net/leva345/article/details/131371193
今日推荐