<nested>标签的作用

 

我先借鉴一个前辈的帖子:

比如我有一个UserInfo类和一个Address类,前者记录用户的帐号密码,后者记录用户的详细信息。前者也有一个Address属性,这样它们两者是嵌套了。
一种方式是在actionForm中用两个属性UserInfo和Address。

<nested:nest property="userInfo">
   <tr align="center">
      <td width="88" height="30">用&nbsp;户&nbsp;名:</td>
      <td width="203"><nested:text property="useraccount" size="30"/></td>
   </tr>
   <tr align="center">
      <td height="30">密&nbsp;&nbsp;&nbsp;&nbsp;码:</td>
      <td><nested:password property="password"  size="30"/></td>
   </tr>

 </nested:nest> 
    <nested:nest property="address">
       <tr align="center">
           <td height="30">用户地址:</td>
           <td><nested:text property="streetOne"  size="30"/></td>
     </tr>
     </nested:nest>

再有一种方式在actionForm中用一个属性UserInfo,因为Address是UserInfo的一个属性。

<nested:nest property="userInfo">
   <tr align="center">
      <td width="88" height="30">用&nbsp;户&nbsp;名:</td>
      <td width="203"><nested:text property="useraccount" size="30"/></td>
   </tr>
   <tr align="center">
      <td height="30">密&nbsp;&nbsp;&nbsp;&nbsp;码:</td>
      <td><nested:password property="password"  size="30"/></td>
   </tr>
    <nested:nest property="address">
       <tr align="center">
           <td height="30">用户地址:</td>
           <td><nested:text property="streetOne"  size="30"/></td>
     </tr>
     </nested:nest>
</nested:nest>

对比下第二种方法更简便

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
代码报错<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:comtext="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> <!-- 1 准备目标类 --> <bean id="personDao" class="com.sc.spring.dao.impl.PersonDaoImpl"></bean> <!-- 2 准备增强类 --> <bean id="myAdvice" class="com.sc.spring.utils.MyAdvice"></bean> <!-- 3 织入 将增强类的增强方法应用到目标类的目标方法前后 --> <aop:config> <!-- pointcut标签声明切入点表达式 切入点表达式就是一种规则 spring aop根据规则找到满足规则的目标方法 然后对目标方法前后进行指定增强 --> <aop:pointcut id="pc" expression="execution(public boolean com.sc.spring.dao.impl.PersonDaoImpl.getPersonByUsernameAndPwd(java.lang.String,java.lang.String))"></aop:pointcut> <aop:aspect ref="myAdvice"> <!-- aop:before标签代表配置前置通知 method属性是配置增强类中哪个方法作为前置通知执行 --> <aop:before method="before" pointcut-ref="pc"></aop:before> </aop:aspect> </aop:config> </beans>报错问题是org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 22 in XML document from class path resource [aop.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 17; cvc-complex-type.2.4.c: 通配符的匹配很全面, 但无法找到元素 'aop:config' 的声明。
最新发布
06-06

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值