zoukankan      html  css  js  c++  java
  • Struts2 extends用法

    1.创建一个struts-extends.xml文件

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts PUBLIC
    	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    	"http://struts.apache.org/dtds/struts-2.3.dtd">
    	<!-- 
    		在package中,只要继承了struts-default,就用了name为struts-default的包里面的所有的功能
    		而struts-default包在struts-default.xml文件中
    		所以必须继承struts-default
    	 -->
    	<struts>
    		<package name="person" namespace="/base" extends="struts-default">
    			<action name="personAction" class="com.struts2.action.extend.PersonAction">
    				<result name="person">success.jsp</result>
    			</action>
    		</package>
    		
    			<!-- 
    		在包中
    			extends="person"
    			说明这个包具有了person包的所有的功能
    		 -->
    		 
    		<package name="student" namespace="/student" extends="person">
    			
    		</package>
    	</struts>
    
    <a href="${pageContext.request.contextPath}/student/personAction.action">有命名空间</a><br>

    2.在src目录下的struts.xml中引入这个xml文件

    <include file="com/struts2/action/extend/struts-extends.xml"></include>
    

     

    3.这样就可以在请求中请求它了,它具有person的所有属性,并且自己还可以加

  • 相关阅读:
    cogs 1272. [AHOI2009] 行星序列
    1027. 打印沙漏(20)
    1026. 程序运行时间(15)
    1023. 组个最小数 (20)
    《C语言程序设计(第四版)》阅读心得(四 文件操作)
    1022. D进制的A+B (20)
    1021. 个位数统计 (15)
    1020. 月饼 (25)
    1015. 德才论 (25)
    1009. 说反话 (20)
  • 原文地址:https://www.cnblogs.com/callyblog/p/7460507.html
Copyright © 2011-2022 走看看