「最も」構成を簡略化したStruts 2はAnnotationスタイルに基づいている.


キーはやはりAnnotationの方式に基づいてStruts 2を配置して、使うバージョンは2.1.6です.
個人の記憶だけでなく、今後も使いやすいです.
Struts 2に必要なのは、クラスパスの下のstruts.xmlです.  下のように配置されていますが、ほとんどは省略できます.


<?xml version="1.0" encoding="UTF-8" ?> 
<!--  struts2     DTD  --> 
<!DOCTYPE struts PUBLIC 
"-//apache Software Foundation//DTD Struts Configuation 2.0//EN" 
"http://struts.apache.org/dtds/struts-2.0.dtd"> 
<!-- struts  struts2        --> 
<struts> 
    <!--  Struts 2          --> 
<constant name="struts.devMode" value="true"></constant> 
<!--  Http     ,          --> 
<constant name="struts.i18n.reload" value="true"></constant> 
<!--struts.xml       ,           --> 
<constant name="struts.configuration.xml.reload" value="true"></constant> 
<!--  web        --> 
<constant name="struts.i18n.encoding" value="UTF-8"></constant> 
<!--          --> 
<constant name="struts.custom.i18n.resources" value="messageResource"></constant> 
<!--    Struts 2       --> 
<constant name="struts.action.extension" value="jspa" /> 
<!--struts2 Action             --> 
<package name="strutsqs" extends="struts-default">  
  <global-results> 
   <!--    login    ,  /login/login.jsp     -->   
   <result name="common_error">/deal/error.jsp</result> 
  </global-results>  
</package> 
<include file="struts-user.xml"></include> 
</struts> 
必要なjarバッグは以下の通りです.
freemarker-23.13.jar/使うところがあります.
struts 2-codebehind-plugin-2.16.jar    //Annotationスタイルの設定に使用します.
struts 2-config-browser-plugin-2.16.jar/同上
struts 2-core-2.16.jar/コアパック
struts 2-spring-plugin-2.16.jar/用とSpring統合
xwork-2.1.jar                        //もう一つのコアバッグ
ognl-2.6.11.jar/依存カバン
javassist-3.4.GA.jar                   //同じ時期に必要なカバンです.JunnitとSpringを統合するためのものです.

@ParentPackage("struts-default")  //        ,     
@Namespace("")			//          
@Results( { @Result(value = "/sayHello.jsp") }) //      ,   name success,       
public class HelloAction extends ActionSupport {
	public String SayHello() {
		System.out.println("    action");
		return "success";
	}

	public String execute() {
		System.out.println("Access Success!!!");
		return "success";
	}
}
ここで注意して訪問するアクションでは、名前はクラス名の最初の小文字hello.actionで、その中の後ろのアクション部分は書かなくてもいいです.
他はweb.xmlに配置されています.

<!--    Spring    -->
<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext*.xml
                  </param-value>
</context-param>

<!-- Character Encoding filter       (  ) -->
	<filter>
		<filter-name>encodingFilter</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-mapping>
		<filter-name>encodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

<!-- Struts2 filter,actionPackages    Action    , Annotation     -->
	<filter>
	<filter-name>struts2</filter-name>
	<filter-class>
          org.apache.struts2.dispatcher.FilterDispatcher
         </filter-class>
	   <init-param>
		<param-name>actionPackages</param-name>
		<param-value>com.orz.view.struts</param-value>
	   </init-param>
	</filter>

	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>*.action</url-pattern>
	</filter-mapping>

	<!--Spring ApplicationContext    -->
	<listener>
	<listener-class>
         org.springframework.web.context.ContextLoaderListener
         </listener-class>
	</listener>
	<!-- Spring   Introspector      (  ) -->
	<listener>
	
         <listener-class>
	org.springframework.web.util.IntrospectorCleanupListener
         </listener-class>
	</listener>