struts.xml配置文件,前台使用ajax请求对应的action,使用json的方式必须引入 以上的包。这些包部分来源 struts2.3.5的 blank lib目录下。想要整合spring struts2-core,struts2-json-plugin,strtus2-spring-plugin;
<package name="mainPackage" namespace="/pages" extends="json-default"> <action name="homePage" class="com.yzx.function.home.action.HomePageAction" method="initMethod"> <result name="data2Page" type="json"> <param name="root">data2Page</param> </result> </action> </package>
web.xml配置
如果不想把struts文件放在src根目录则可以配置init-param,以下3个文件一个都不能少
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:com/yzx/system/conf/spring/applicationContext*.xml</param-value> </context-param> <!--配置struts--> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>config</param-name> <param-value>struts-default.xml,struts-plugin.xml,com/yzx/system/conf/struts/struts.xml</param-value> </init-param> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
页面刷新既可以请求到后台的