web.xml
struts-config.xml
validator-rules.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" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>encoding</filter-name>
<filter-class>
org.lxh.myzngt.filter.EncodingFilter
</filter-class>
<init-param>
<param-name>charset</param-name>
<param-value>gbk</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>userlogin</filter-name>
<filter-class>
org.lxh.myzngt.filter.UserLoginFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>userlogin</filter-name>
<url-pattern>/jsp/user/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>userlogin</filter-name>
<url-pattern>/jsp/ques/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>adminlogin</filter-name>
<filter-class>
org.lxh.myzngt.filter.AdminLoginFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>adminlogin</filter-name>
<url-pattern>/jsp/admin/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>opensession</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>opensession</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
</param-value>
</context-param>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<form-beans>
<form-bean name="userForm"
type="org.lxh.myzngt.struts.form.UserForm" />
<form-bean name="questionForm"
type="org.lxh.myzngt.struts.form.QuestionForm" />
<form-bean name="answerForm"
type="org.lxh.myzngt.struts.form.AnswerForm" />
<form-bean name="itemForm"
type="org.lxh.myzngt.struts.form.ItemForm" />
<form-bean name="indexForm"
type="org.apache.struts.action.DynaActionForm" />
<form-bean name="showForm"
type="org.apache.struts.action.DynaActionForm" />
<form-bean name="userinfoForm"
type="org.apache.struts.action.DynaActionForm" />
<form-bean name="adminForm"
type="org.lxh.myzngt.struts.form.AdminForm" />
<form-bean name="adminuserForm"
type="org.lxh.myzngt.struts.form.AdminuserForm" />
<form-bean name="adminquestionForm"
type="org.apache.struts.action.DynaActionForm" />
<form-bean name="adminitemForm"
type="org.lxh.myzngt.struts.form.AdminitemForm" />
<form-bean name="adminsubitemForm"
type="org.lxh.myzngt.struts.form.AdminsubitemForm" />
<form-bean name="adminloginForm"
type="org.lxh.myzngt.struts.form.AdminloginForm" />
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings>
<action attribute="userForm" input="/jsp/errors.jsp"
name="userForm" parameter="status" path="/jsp/user" scope="request"
type="org.lxh.myzngt.struts.action.UserAction">
<forward name="registersuccess"
path="/jsp/index.do?status=list">
</forward>
<forward name="registerfailure" path="/jsp/register.jsp"></forward>
<forward name="loginsuccess"
path="/jsp/index.do?status=list">
</forward>
<forward name="loginfailure" path="/jsp/login.jsp"></forward>
<forward name="exists" path="/jsp/updatepwd.jsp"></forward>
<forward name="notexists" path="/jsp/forgetpwd.jsp"></forward>
<forward name="updatepwddo" path="/jsp/updatepwd_do.jsp"></forward>
<forward name="userinfo" path="/jsp/user/userinfo.jsp"></forward>
<forward name="updatedo" path="/jsp/user/update_do.jsp"></forward>
</action>
<action attribute="questionForm" input="/jsp/errors.jsp"
name="questionForm" parameter="status" path="/jsp/ques/question"
scope="request" type="org.lxh.myzngt.struts.action.QuestionAction">
<forward name="insertdo" path="/jsp/ques/question_do.jsp"></forward>
</action>
<action attribute="answerForm" input="/jsp/errors.jsp"
name="answerForm" parameter="status" path="/jsp/ques/answer"
scope="request" type="org.lxh.myzngt.struts.action.AnswerAction">
<forward name="insertdo" path="/jsp/ques/answer_do.jsp"></forward>
</action>
<action attribute="itemForm" input="/jsp/errors.jsp"
name="itemForm" parameter="status" path="/jsp/ques/item"
scope="request" type="org.lxh.myzngt.struts.action.ItemAction">
<forward name="question" path="/jsp/ques/question.jsp"></forward>
</action>
<action attribute="indexForm" input="/jsp/errors.jsp"
name="indexForm" parameter="status" path="/jsp/index" scope="request"
type="org.lxh.myzngt.struts.action.IndexAction">
<forward name="indexdo" path="/jsp/index.jsp"></forward>
</action>
<action attribute="showForm" input="/jsp/errors.jsp"
name="showForm" parameter="status" path="/jsp/show" scope="request"
type="org.lxh.myzngt.struts.action.ShowAction">
<forward name="showquestion"
path="/jsp/question_show.jsp">
</forward>
<forward name="showlist" path="/jsp/list_question.jsp"></forward>
</action>
<action attribute="userinfoForm" input="/jsp/errors.jsp"
name="userinfoForm" parameter="status" path="/jsp/user/userinfo"
scope="request" type="org.lxh.myzngt.struts.action.UserinfoAction">
<forward name="listmyquestion"
path="/jsp/user/list_myquestion.jsp">
</forward>
<forward name="listanswer"
path="/jsp/user/list_answer.jsp">
</forward>
<forward name="listmyaccept"
path="/jsp/user/list_myaccept.jsp">
</forward>
<forward name="listmyquestionanswer"
path="/jsp/user/list_myquestionanswer.jsp">
</forward>
<forward name="answerdo"
path="/jsp/user/accept_answer.jsp">
</forward>
<forward name="updatequestiondo"
path="/jsp/user/question_update_do.jsp">
</forward>
</action>
<action attribute="adminForm" input="/jsp/errors.jsp"
name="adminForm" parameter="status" path="/jsp/admin/admin"
scope="request" type="org.lxh.myzngt.struts.action.AdminAction">
<forward name="insertdo"
path="/jsp/admin/admin.do?status=list">
</forward>
<forward name="updatepwddo"
path="/jsp/admin/admin_updatepwd_do.jsp">
</forward>
<forward name="updatepwdfailure"
path="/jsp/admin/admin_updatepwd.jsp">
</forward>
<forward name="deletedo"
path="/jsp/admin/admin.do?status=list">
</forward>
<forward name="list" path="/jsp/admin/admin_list.jsp"></forward>
</action>
<action attribute="adminuserForm" input="/jsp/errors.jsp"
name="adminuserForm" parameter="status" path="/jsp/admin/adminuser"
scope="request"
type="org.lxh.myzngt.struts.action.AdminuserAction">
<forward name="userlist" path="/jsp/admin/user_list.jsp"></forward>
<forward name="list"
path="/jsp/admin/adminuser.do?status=list">
</forward>
</action>
<action attribute="adminquestionForm" input="/jsp/errors.jsp"
name="adminquestionForm" parameter="status"
path="/jsp/admin/adminquestion" scope="request"
type="org.lxh.myzngt.struts.action.AdminquestionAction">
<forward name="questionlist"
path="/jsp/admin/question_list.jsp">
</forward>
<forward name="list"
path="/jsp/admin/adminquestion.do?status=list">
</forward>
</action>
<action attribute="adminitemForm" input="/jsp/errors.jsp"
name="adminitemForm" parameter="status" path="/jsp/admin/adminitem"
scope="request"
type="org.lxh.myzngt.struts.action.AdminitemAction">
<forward name="itemlist" path="/jsp/admin/item_list.jsp"></forward>
<forward name="list"
path="/jsp/admin/adminitem.do?status=list">
</forward>
<forward name="subitemlist"
path="/jsp/admin/subitem_list.jsp">
</forward>
</action>
<action attribute="adminsubitemForm" input="/jsp/errors.jsp"
name="adminsubitemForm" parameter="status"
path="/jsp/admin/adminsubitem" scope="request"
type="org.lxh.myzngt.struts.action.AdminsubitemAction">
<forward name="subitemlist"
path="/jsp/admin/subitem_list.jsp">
</forward>
</action>
<action attribute="adminloginForm" input="/jsp/errors.jsp"
name="adminloginForm" parameter="status" path="/jsp/adminlogin"
scope="request"
type="org.lxh.myzngt.struts.action.AdminloginAction">
<forward name="loginsuccess"
path="/jsp/goadmin.htm">
</forward>
<forward name="loginfailure"
path="/jsp/admin_login.jsp">
</forward>
</action>
</action-mappings>
<controller
processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
</controller>
<message-resources
parameter="org.lxh.myzngt.struts.ApplicationResources" />
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/classes/applicationContext.xml" />
</plug-in>
</struts-config>
validator-rules.xml
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<!--
$Id: validator-rules.xml,v 1.1.2.1 2006/07/01 20:50:46 eugene-proddev Exp $
This file contains the default Struts Validator pluggable validator
definitions. It should be placed somewhere under /WEB-INF and
referenced in the struts-config.xml under the plug-in element
for the ValidatorPlugIn.
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
These are the default error messages associated with
each validator defined in this file. They should be
added to your projects ApplicationResources.properties
file or you can associate new ones by modifying the
pluggable validators msg attributes in this file.
# Struts Validator Error Messages
errors.required={0} is required.
errors.minlength={0} can not be less than {1} characters.
errors.maxlength={0} can not be greater than {1} characters.
errors.invalid={0} is invalid.
errors.byte={0} must be a byte.
errors.short={0} must be a short.
errors.integer={0} must be an integer.
errors.long={0} must be a long.
errors.float={0} must be a float.
errors.double={0} must be a double.
errors.date={0} is not a date.
errors.range={0} is not in the range {1} through {2}.
errors.creditcard={0} is an invalid credit card number.
errors.email={0} is an invalid e-mail address.
Note: Starting in Struts 1.2.0 the default javascript definitions have
been consolidated to commons-validator. The default can be overridden
by supplying a <javascript> element with a CDATA section, just as
in struts 1.1.
-->
<form-validation>
<global>
<validator name="required"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
msg="errors.required"/>
<validator name="requiredif"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequiredIf"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
msg="errors.required"/>
<validator name="validwhen"
msg="errors.required"
classname="org.apache.struts.validator.validwhen.ValidWhen"
method="validateValidWhen"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"/>
<validator name="minlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMinLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.minlength"
jsFunction="org.apache.commons.validator.javascript.validateMinLength"/>
<validator name="maxlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMaxLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.maxlength"
jsFunction="org.apache.commons.validator.javascript.validateMaxLength"/>
<validator name="mask"
classname="org.apache.struts.validator.FieldChecks"
method="validateMask"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.invalid"/>
<validator name="byte"
classname="org.apache.struts.validator.FieldChecks"
method="validateByte"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.byte"
jsFunctionName="ByteValidations"/>
<validator name="short"
classname="org.apache.struts.validator.FieldChecks"
method="validateShort"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.short"
jsFunctionName="ShortValidations"/>
<validator name="integer"
classname="org.apache.struts.validator.FieldChecks"
method="validateInteger"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.integer"
jsFunctionName="IntegerValidations"/>
<validator name="long"
classname="org.apache.struts.validator.FieldChecks"
method="validateLong"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.long"/>
<validator name="float"
classname="org.apache.struts.validator.FieldChecks"
method="validateFloat"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.float"
jsFunctionName="FloatValidations"/>
<validator name="double"
classname="org.apache.struts.validator.FieldChecks"
method="validateDouble"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.double"/>
<validator name="date"
classname="org.apache.struts.validator.FieldChecks"
method="validateDate"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.date"
jsFunctionName="DateValidations"/>
<validator name="intRange"
classname="org.apache.struts.validator.FieldChecks"
method="validateIntRange"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends="integer"
msg="errors.range"/>
<validator name="floatRange"
classname="org.apache.struts.validator.FieldChecks"
method="validateFloatRange"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends="float"
msg="errors.range"/>
<validator name="doubleRange"
classname="org.apache.struts.validator.FieldChecks"
method="validateDoubleRange"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends="double"
msg="errors.range"/>
<validator name="creditCard"
classname="org.apache.struts.validator.FieldChecks"
method="validateCreditCard"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.creditcard"/>
<validator name="email"
classname="org.apache.struts.validator.FieldChecks"
method="validateEmail"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.email"/>
<validator name="url"
classname="org.apache.struts.validator.FieldChecks"
method="validateUrl"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.url"/>
<!--
This simply allows struts to include the validateUtilities into a page, it should
not be used as a validation rule.
-->
<validator name="includeJavaScriptUtilities"
classname=""
method=""
methodParams=""
depends=""
msg=""
jsFunction="org.apache.commons.validator.javascript.validateUtilities"/>
</global>
</form-validation>