struts2 基本用法
Struts2必需库: commons-fileupload.jar、commons-io-1.3.2.jar、freemarker-2.3.16.jar、javassist-3.7.ga.jar、ognl-3.0.jar、
struts-core-2.2.1.jar和xwork-core-2.2.1.jar
============================================================
struts.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.devMode" value="false" /> <constant name="struts.ui.theme" value="simple"/> <constant name="struts.i18n.encoding" value="UTF-8" /> <!-- <constant name="struts.custom.i18n.resources" value="resources/framework/messages/messages-common, resources/framework/messages/messages-welcome, resources/framework/messages/messages-exception, resources/framework/messages/messages-admin, resources/framework/messages/messages-dictionary, resources/framework/messages/messages-cnapsmanage, resources/framework/messages/messages-clearing"/> --> <!-- 上传文件大小限制 ,最大不超过100M--> <constant name="struts.multipart.maxSize" value="104857600"/> <!--<constant name="struts.multipart.saveDir" value="/opt/apache-tomcat-6.0.43/temp"/>--> <constant name="struts.action.extension" value="do" /> <package name="BasePackage" extends="json-default" namespace="/system"> <interceptors> <!-- <interceptor name="AppExceptionHandler" class="com.agree.framework.struts2.interceptors.ExceptionHandlerInterceptor"></interceptor> <interceptor name="ActionLogger" class="com.agree.framework.struts2.interceptors.ActionLoggingInterceptor"></interceptor> --> <interceptor name="PrivilegeJudger" class="com.agree.framework.struts2.interceptors.PrivilegeJudgeInterceptor"></interceptor> <interceptor name="DownloadPrivilege" class="com.agree.framework.struts2.interceptors.DownloadPrivilegeInterceptor"/> <!-- <interceptor-stack name="SystemConsoleInterceptorStack"> <interceptor-ref name="PrivilegeJudger"></interceptor-ref> <interceptor-ref name="ActionLogger"></interceptor-ref> <interceptor-ref name="AppExceptionHandler"></interceptor-ref> <interceptor-ref name="defaultStack"></interceptor-ref> </interceptor-stack> --> </interceptors> <global-results> <!-- <result name="login">/webpages/freamwork/welcome/welcomeTimeOut.jsp</result> <result name="nologin">/webpages/freamwork/welcome/nologin.jsp</result> <result name="APPEXCEPTION">/webpages/freamwork/exception/exception.jsp</result> <result name="AJAX_SUCCESS" type="json"> <param name="ignoreHierarchy">false</param> <param name="includeProperties">actionresult</param> </result> --> <result name="noSecurity">/noSecurity.jsp</result> </global-results> <!-- 系统登录 --> <action name="logon_*" class="LogonActionBean" method="{1}"> <!-- <interceptor-ref name="SystemConsoleInterceptorStack"></interceptor-ref> --> <result name="success" type="json"></result> <result name="redirect">/Pages/Layout/index.jsp</result> <result name="logout">/Pages/Layout/login.jsp</result> <result name="tologin">/Pages/Layout/login.jsp</result> </action> </package> <include file="resources/framework/struts2//struts-layout.xml"></include> <include file="resources/framework/struts2//struts-access.xml"></include> <include file="resources/framework/struts2//struts-example.xml"></include> <include file="resources/framework/struts2//struts-config.xml"></include> <include file="resources/framework/struts2//struts-ide.xml"></include> </struts>