一、项目背景
为实现方便用户使用系统的要求,开发后台帮助中心管理系统,实现帮助系统的动态增加,类似于 FAQ 系统。
二、系统概述
本系统架构使用Webwork+Freemarker+Lunene+dom4j.前台搜索使用Lunene-2.0,数据存储使用XML文件存储。实现类似于FAQ系统的快速寻找帮助所需信息。系统可以按类别将问题分类,而且分类可以动态在后台进行添加,可以方便用户进行分类查找,后台同时提供对问题进行增加,删除,编辑操作,提供前台搜索功能的重建索引文件功能
三、系统要求
开发环境: JDK1.5 Tomcat 5.5.9 Jbuilder2006 WindowXP
第三方类库:dom4j- 1.6.1 webwork-2.2.2 log4j-1.2.8 securityFilter2.0 FCKeditor2.3 lucene-2.0.0
四、系统预览
1、按类别查询,点击类别导航栏的类别,查询该类别的所有问题内容
2、按关键字查询,多个关键字以空格分开,对关键字进行加亮显示,如下图所示
3、后台登陆
3、修改密码
4 、问题类别管理,全部类别数据以 XML 文件 Catalog.xml 进行数据存储
5、问题列表,按问题类别进行查询,可以对问题进行增加、删除,编辑操作,属于同一类别的问题数据存于一个XML文件,XML文件名由类别管理功能指定,如上“订购方式”-》SpeakFor.xml
6、问题编辑,用Fckeditor作编辑器,方便数据录入
7、索引管理,对前台搜索索引文件重建索引,保正搜索数据与XML存储的数据一致性
五、需求分析
帮助中心管理系统分为两部分:
前台部分,主要是提供对问题查询的快速操作,搜索功能的实现采用Lunene2.0进行全文搜索
后台部分,分为修改个人密码、问题类别管理-》可以对问题进行分类,每一个分类用一个XML文件进行数据存储,即同属一个类别的问题内容存储于同一个XML文件内,用户可以对问题类别名进行修改,但文件名不提供修改功能,因为文件名定下来就不用怎么变动。问题管理,用户可以对问题进行增加、删除、编辑操作,同时具备同步更新索引文件的功能
六、模块分析
七、详细设计
1、HelpConfig.properties
#helpPath is the home directory installed of Help.
#Warning: Don't add '/' at the end
helpPath=F:/NewJProjects/Help/Help
#The directory of the lucene default: %Help_home%/index
indexPath=F:/NewJProjects/Help/Help/index
#The color of keyword which is specificed by user
keyWordColor=#FF7101
2、freemarker.properties
locale=zh_CN
default_encoding=UTF-8
3、log4j.properties
log4j.rootLogger=INFO,stdout
#DEBUG,CONSOLE,FILE,ROLLING_FILE,MAIL,DATABASE,im,HTML,LF5_APPENDER
log4j.addivity.org.apache=true
#level:是日记记录的优先级,优先级由高到低分为 OFF ,FATAL ,ERROR ,WARN ,INFO ,DEBUG ,ALL。
#Log4j建议只使用FATAL ,ERROR ,WARN ,INFO ,DEBUG这四个级别。
###################
# stdout
###################
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
log4j.logger.com.mxca = DEBUG
###################
#DEBUG
##################
log4j.appender.DEBUG=org.apache.log4j.ConsoleAppender
log4j.appender.DEBUG.layout=org.apache.log4j.PatternLayout
log4j.appender.DEBUG.layout.ConversionPattern=%5p [%t] - %m%n
###################
###################
#ERROR
##################
log4j.appender.ERROR=org.apache.log4j.ConsoleAppender
log4j.appender.ERROR.layout=org.apache.log4j.PatternLayout
log4j.appender.ERROR.layout.ConversionPattern=%5p [%t] - %m%n
###################
###################
#INFO
##################
log4j.appender.INFO=org.apache.log4j.ConsoleAppender
log4j.appender.INFO.layout=org.apache.log4j.PatternLayout
log4j.appender.INFO.layout.ConversionPattern=%5p [%t] - %m%n
4、webwork.properties
### Webwork default properties
###(can be overridden by a webwork.properties file in the root of the classpath)
###
### Specifies the Configuration used to configure webwork
### one could extend com.opensymphony.webwork.config.Configuration
### to build one's customize way of getting the configurations parameters into webwork
# webwork.configuration=com.opensymphony.webwork.config.DefaultConfiguration
### This can be used to set your default locale and encoding scheme
webwork.locale=zh_CN
webwork.i18n.encoding=UTF-8
### if specified, the default object factory can be overridden here
### Note: short-hand notation is supported in some cases, such as "spring"
### Alternatively, you can provide a com.opensymphony.xwork.ObjectFactory subclass name here
webwork.objectFactory = spring
### specifies the autoWiring logic when using the SpringObjectFactory.
### valid values are: name, type, auto, and constructor (name is the default)
webwork.objectFactory.spring.autoWire = name
### if specified, the default object type determiner can be overridden here
### Note: short-hand notation is supported in some cases, such as "tiger" or "notiger"
### Alternatively, you can provide a com.opensymphony.xwork.util.ObjectTypeDeterminer implementation name here
### Note: if you have the xwork-tiger.jar within your classpath, GenericsObjectTypeDeterminer is used by default
### To disable tiger support use the "notiger" property value here.
#webwork.objectTypeDeterminer = tiger
#webwork.objectTypeDeterminer = notiger
### Parser to handle HTTP POST requests, encoded using the MIME-type multipart/form-data
# webwork.multipart.parser=cos
# webwork.multipart.parser=pell
webwork.multipart.parser=jakarta
# uses javax.servlet.context.tempdir by default
#webwork.multipart.saveDir=F://FilesUpload
webwork.multipart.maxSize=2097152
### Load custom property files (does not override webwork.properties!)
# webwork.custom.properties=application,com/webwork/extension/custom
### How request URLs are mapped to and from actions
webwork.mapper.class=com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper
### Used by the DefaultActionMapper
webwork.action.extension=jspx
### use alternative syntax that requires %{} in most places
### to evaluate expressions for String attributes for tags
webwork.tag.altSyntax=true
### when set to true, WebWork will act much more friendly for developers. This
### includes:
### - webwork.i18n.reload = true
### - webwork.configuration.xml.reload = true
### - raising various debug or ignorable problems to errors
### For example: normally a request to foo.action?someUnknownField=true should
### be ignored (given that any value can come from the web and it
### should not be trusted). However, during development, it may be
### useful to know when these errors are happening and be told of
### them right away.
webwork.devMode = false
### when set to true, resource bundles will be reloaded on _every_ request.
### this is good during development, but should never be used in production
webwork.i18n.reload=true
### Standard UI theme
### Change this to reflect which path should be used for JSP control tag templates by default
webwork.ui.theme=xhtml
webwork.ui.templateDir=template
#sets the default template type. Either ftl, vm, or jsp
webwork.ui.templateSuffix=ftl
### Configuration reloading
### This will cause the configuration to reload xwork.xml when it is changed
webwork.configuration.xml.reload=true
### Location of velocity.properties file. defaults to velocity.properties
# webwork.velocity.configfile = velocity.properties
### Comma separated list of VelocityContext classnames to chain to the WebWorkVelocityContext
# webwork.velocity.contexts =
### used to build URLs, such as the UrlTag
webwork.url.http.port = 80
webwork.url.https.port = 443
### Load custom default resource bundles
webwork.custom.i18n.resources=ApplicationResources_en,ApplicationResources_zh_CN
### workaround for some app servers that don't handle HttpServletRequest.getParameterMap()
### often used for WebLogic, Orion, and OC4J
webwork.dispatcher.parametersWorkaround = false
### configure the Freemarker Manager class to be used
### Allows user to plug-in customised Freemarker Manager if necessary
### MUST extends off com.opensymphony.webwork.views.freemarker.FreemarkerManager
#webwork.freemarker.manager.classname=com.opensymphony.webwork.views.freemarker.FreemarkerManager
### See the WebWorkBeanWrapper javadocs for more information
webwork.freemarker.wrapper.altMap=true
5、ApplicationResources.properties ApplicationResources_zh_CN.properties
html.common.title.operate=操作
html.common.title.delete=删除
html.common.title.edit=编辑
html.common.title.save=保存
html.common.title.search=查询
html.common.title.catalog=问题类别
html.common.title.add=增加
html.common.title.question.title=问题主题
html.common.title.question.content=内容
html.common.title.return=返回
html.common.title.delete.confirm=你确定删除此条记录吗?
html.Login.msg.not.input.username=请输入用户名
html.Login.msg.not.input.password=请输入密码
html.Login.title.username=用户名
html.Login.title.passowrd=密 码
html.Login.title.submit=登陆
html.Login.title.system=系统登陆
html.Top.help.title.manager=管理
html.Top.help.title.help.search=帮助搜索
html.Menu.admin.title.menu=系统菜单
html.Menu.admin.item.user.manager=修改密码
html.Menu.admin.item.catalog.manager=类别管理
html.Menu.admin.item.index.manager=搜索管理
html.Menu.admin.item.question.manager=问题管理
html.Top.admin.title.current.user=当前用户
html.Top.admin.title.logout=退出
html.Main.title.help.center=帮助中心后台管理系统
html.Help.title=帮助中心
html.Help.title.search.tip=请输入关键字,多个关键字之间使用空格分隔
html.ChangePwd.title=修改密码
html.ChangePwd.title.username=用户名
html.ChangePwd.title.old.password=旧密码
html.ChangePwd.title.new.password=新密码
html.ChangePwd.title.new.passowrd.again=重 复
html.ChangePwd.title.change=修改
html.ChangePwd.error.new.and.old.password.not.the.same=旧密码和新密码不一致
html.ChangePwd.msg.pls.input.old.password=请输入旧密码
html.ChangePwd.msg.pls.input.new.password=请输入新密码
html.ChangePwd.msg.pls.input.new.password.again=请再次输入新密码
html.Catalog.title=类别管理
html.Catalog.title.catalog.id=类别ID
html.Catalog.title.question.file.name=文件名称
html.Catalog.title.list=类别列表
html.Catalog.title.add=增加类别
html.Catalog.msg.pls.input.catalog.name=请输入类别名称
html.Catalog.msg.pls.input.catalog.src=请输入文件名称
html.Catalog.msg.input.catalog.src.error=你输入的文件名后缀有误,文件后缀必须是.xml
html.Catalog.msg.delete.confirm=你确定删除该类别吗?
html.Question.title=问题管理
html.Question.title.list=问题列表
html.Question.title.quesion.id=问题ID
html.Question.title.not.set.catalog=你还没有设置问题类别,请在[类别管理]增加类别
html.Question.title.reply.status=回复状态
html.Question.title.reply.status.pls.select=请选择
html.Question.title.reply.status.has.replied=已回复
html.Question.title.reply.status.has.not.replied=未回复
html.QuestionAdd.title=增加问题
html.QuestionAdd.msg.pls.input.subject=请输入问题主题
html.QuestionUpdate.title=编辑问题
html.Help.not.input.keyword=请输入搜索关键字!
html.IndexFileList.title=索引文件列表
html.IndexFileList.title.file.name=文件名
html.IndexFileList.title.file.size=大小
html.IndexFileList.title.file.modify.date=创建时间
html.IndexFileList.reindex=重做索引
msg.help.change.password=密码更改成功
msg.help.delete.catalog.success=删除类别成功
msg.help.update.catalog.success=更新类别成功
msg.help.add.catalog.success=增加类别成功
msg.help.list.question.not.result=没有符合条件的记录
msg.help.add.question.success=增加问题成功
msg.help.update.question.success=更新问题成功
msg.help.delete.question.success=删除问题成功
msg.help.add.question.index.success=增加索引成功
msg.help.update.question.index.success=更新索引成功
msg.help.delete.question.index.success=删除索引成功
msg.help.search.by.keyword=查询结果导航
msg.help.search.by.keyword.no.result=没有匹配关键字[{0}]帮助记录,请重新输入其它关键字进行搜索!
msg.help.search.by.catalog.no.result=问题类别 [{0}] 没有任何记录!
msg.help.delete.index.file.success=索引文件名: [{0}] 大小:[{1}] 删除成功!
error.help.change.password=密码更改失败
error.help.login.userId.or.password.not.right=用户或密码不正确,请重新输入!
error.help.delete.catalog.fail=删除类别失败
error.help.update.catalog.fail=更新类别失败
error.help.add.catalog.fail=增加类别失败
error.help.add.question.fail=增加问题失败
error.help.update.question.fail=更新问题失败
error.help.delete.question.fail=删除问题失败
error.help.add.question.index.fail=删除索引失败
error.help.update.question.index.fail=更新索引失败
error.help.delete.question.index.fail=删除索引失败
msg.help.delete.index.file.fail=索引文件名: [{0}] 大小:[{1}] 删除失败!
6、xwork.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.1.1//EN" "http://www.opensymphony.com/xwork/xwork-1.1.1.dtd">
<xwork>
<include file="webwork-default.xml"/>
<package name="default" extends="webwork-default">
<action name="help" class="com.mxca.shop4i.Help.action.BaseAction" method="doDefault">
<result name="success" type="freemarker">
<param name="location">/templates/help/Help.html</param>
</result>
</action>
<action name="search" class="com.mxca.shop4i.Help.action.help.HelpAction" method="doSearch">
<result name="success" type="freemarker">
<param name="location">/templates/help/Help.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="login" class="com.mxca.shop4i.Help.action.BaseAction" method="doLogin">
<result name="success" type="freemarker">
<param name="location">/templates/admin/Login.html</param>
</result>
</action>
<action name="logError" class="com.mxca.shop4i.Help.action.BaseAction" method="doLogError">
<result name="error" type="freemarker">
<param name="location">/templates/admin/Login.html</param>
</result>
</action>
<action name="logout" class="com.mxca.shop4i.Help.action.BaseAction" method="doLogout">
<result name="success" type="chain">
<param name="actionName">help</param>
</result>
</action>
</package>
<package name="Admin" extends="default" namespace="/Admin">
<action name="main" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doDefault">
<result name="success" type="freemarker">
<param name="location">/templates/admin/Main.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="top" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doDefault">
<result name="success" type="freemarker">
<param name="location">/templates/admin/Top.html</param>
</result>
</action>
<action name="menu" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doDefault">
<result name="success" type="freemarker">
<param name="location">/templates/admin/Menu.html</param>
</result>
</action>
<action name="logSuccess" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doDefault">
<result name="success" type="freemarker">
<param name="location">/templates/admin/LogSuccess.html</param>
</result>
</action>
<action name="changePwdInput" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doChangePwdInput">
<result name="input" type="freemarker">
<param name="location">/templates/admin/ChangePwd.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="changePwd" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doChangePwd">
<result name="success" type="freemarker">
<param name="location">/templates/admin/ChangePwd.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="catalogList" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doCatalogList">
<result name="success" type="freemarker">
<param name="location">/templates/admin/Catalog.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="delCatalog" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doDelCatalog">
<result name="success" type="freemarker">
<!--
<param name="actionName">catalogList</param>
-->
<param name="location">/templates/admin/Catalog.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="updateCatalog" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doUpdateCatalog">
<result name="success" type="freemarker">
<!--
<param name="actionName">catalogList</param>
-->
<param name="location">/templates/admin/Catalog.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="addCatalog" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doAddCatalog">
<result name="success" type="freemarker">
<!--
<param name="actionName">catalogList</param>
-->
<param name="location">/templates/admin/Catalog.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="questionListInput" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doInput">
<result name="input" type="freemarker">
<param name="location">/templates/admin/Question.html</param>
</result>
</action>
<action name="questionList" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doQuestionList">
<result name="success" type="freemarker">
<param name="location">/templates/admin/Question.html</param>
</result>
<interceptor-ref name="params"/>
<interceptor-ref name="servlet-config"/>
</action>
<action name="questionAddInput" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doInput">
<result name="input" type="freemarker">
<param name="location">/templates/admin/QuestionAdd.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="questionAdd" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doQuestionAdd">
<result name="success" type="freemarker">
<param name="location">/templates/admin/QuestionAdd.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="questionEditInput" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doQuestionEditInput">
<result name="input" type="freemarker">
<param name="location">/templates/admin/QuestionEdit.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="questionEdit" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doQuestionEdit">
<result name="success" type="chain">
<param name="actionName">questionEditInput</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="questionDelete" class="com.mxca.shop4i.Help.action.admin.AdminAction" method="doDeleteQuestion">
<result name="success" type="freemarker">
<param name="location">/templates/admin/Question.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="indexList" class="com.mxca.shop4i.Help.action.admin.IndexAction" method="doIndexList">
<result name="success" type="freemarker">
<param name="location">/templates/admin/IndexFileList.html</param>
</result>
<interceptor-ref name="params"/>
</action>
<action name="reIndex" class="com.mxca.shop4i.Help.action.admin.IndexAction" method="doReIndex">
<result name="success" type="freemarker">
<param name="location">/templates/admin/IndexFileList.html</param>
</result>
<interceptor-ref name="params"/>
</action>
</package>
</xwork>
7、web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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" version="2.4">
<display-name>Help</display-name>
<filter>
<filter-name>Security Filter</filter-name>
<filter-class>org.securityfilter.filter.SecurityFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/securityfilter-config.xml</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Security Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>webwork</filter-name>
<filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>webwork</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>JspSupportServlet</servlet-name>
<servlet-class>com.opensymphony.webwork.views.JspSupportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<description>FCKEditor</description>
<servlet-name>Connector</servlet-name>
<servlet-class>com.fredck.FCKeditor.connector.ConnectorServlet</servlet-class>
<init-param>
<param-name>baseDir</param-name>
<param-value>/UserFiles/</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Connector</servlet-name>
<url-pattern>/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
</servlet-mapping>
<servlet>
<description>FCKEditor</description>
<servlet-name>SimpleUploader</servlet-name>
<servlet-class>com.fredck.FCKeditor.uploader.SimpleUploaderServlet</servlet-class>
<init-param>
<param-name>baseDir</param-name>
<param-value>/UserFiles/</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>enabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsFile</param-name>
<param-value />
</init-param>
<init-param>
<param-name>DeniedExtensionsFile</param-name>
<param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsImage</param-name>
<param-value>jpg|gif|jpeg|png|bmp</param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsImage</param-name>
<param-value />
</init-param>
<init-param>
<param-name>AllowedExtensionsFlash</param-name>
<param-value>swf|fla</param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsFlash</param-name>
<param-value />
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SimpleUploader</servlet-name>
<url-pattern>/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern>
</servlet-mapping>
<jsp-config>
<taglib>
<taglib-uri>WebWork</taglib-uri>
<taglib-location>/WEB-INF/webwork.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://fckeditor.net/tags-fckeditor</taglib-uri>
<taglib-location>/WEB-INF/FCKeditor.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>Page</taglib-uri>
<taglib-location>/WEB-INF/page.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
8、securityfilter-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE securityfilter-config PUBLIC
"-//SecurityFilter.org//DTD Security Filter Configuration 2.0//EN"
"http://www.securityfilter.org/dtd/securityfilter-config_2_0.dtd">
<securityfilter-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>Secure Page</web-resource-name>
<url-pattern>*/Admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>Admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jspx</form-login-page>
<form-error-page>/LogError.jsp</form-error-page>
<form-default-page>/Admin/main.jspx</form-default-page>
<form-logout-page>/logout.jspx</form-logout-page>
</form-login-config>
</login-config>
<realm className="com.mxca.shop4i.Help.security.HelpSecurityRealm" />
</securityfilter-config>
9、HelpConfig.java
package com.mxca.shop4i.Help.util;
import java.util.Properties;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
import java.io.*;
/**
*
* <p>Title: Help</p>
*
* <p>Description: mxca help</p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: mxca</p>
*
* @author Sogui Dai
* @version 1.0
*/
public class HelpConfig {
private static final Log log = LogFactory.getLog(HelpConfig.class);
private static final String CONFIG_FILE = "HelpConfig.properties";
private static final String HELP_PATH_KEY = "helpPath";
private static final String INDEX_PATH="indexPath";
private static final String KEYWORD_COLOR_KEY="keyWordColor";
private static HelpConfig helpConfig;
private Properties properties;
private HelpConfig() {
init();
}
public synchronized static HelpConfig getInstance() {
if(helpConfig==null){
helpConfig= new HelpConfig();
}
return helpConfig;
}
private void init() {
try {
properties = Resources.getResourceAsProperties(CONFIG_FILE);
if (log.isDebugEnabled()) {
log.debug(
CONFIG_FILE + " is loaded successfully.");
}
}
catch (IOException ex) {
log.error(ex.toString());
}
}
public String getHelpPath() {
return properties.getProperty(this.HELP_PATH_KEY, "");
}
public String getIndexPath(){
return properties.getProperty(this.INDEX_PATH,"/index");
}
public String getKeyWordColor(){
return properties.getProperty(this.KEYWORD_COLOR_KEY,"RED");
}
public static void main(String[] args){
System.out.println(HelpConfig.getInstance().getHelpPath());
}
}
10、MD5Coding.java
package com.mxca.shop4i.Help.util;
import java.security.MessageDigest;
/**
*
* <p>Title: Help</p>
*
* <p>Description: mxca help</p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: mxca</p>
*
* @author Sogui Dai
* @version 1.0
*/
public class MD5Coding {
public MD5Coding() {
}
public final static String encode(String s) {
char hexDigits[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd',
'e', 'f'};
try {
byte[] strTemp = s.getBytes();
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
mdTemp.update(strTemp);
byte[] md = mdTemp.digest();
int j = md.length;
char str[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte byte0 = md[i];
str[k++] = hexDigits[byte0 >>