针对这个问题,我问了下osc的大神们,解决方案是在spring的配置中,把vo注入的时候加入属性:scorp=prototype ,但是当时我试了下是没有成功的,后来用了另一种方式,不过我觉得不好,刚刚又去测试了一下,发现加上scorp属性这种方式最简单,而且也成功了,之前没成功的原因是因为我修改的时候没有传id过去。。。汗啊!
方式一:scorp=prototype
<bean name="diaryVO" scope="prototype" class="com.ds.diary.vo.DiaryVO">
方式二:这种方式比较繁琐,也贴出来吧!
1.先在struts.xml中加上一个默认的拦截器:
<package name="global" extends="json-default">
<interceptors>
<interceptor name="exceptionInterceptor" class="com.ds.Interceptor.ExceptionInterceptor"/>
<interceptor-stack name="serverInterceptor">
<interceptor-ref name="defaultStack">
<param name="modelDriven.refreshModelBeforeResult">true</param>
</interceptor-ref>
<interceptor-ref name="exceptionInterceptor"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="serverInterceptor"/>
<global-results>
<result name="server_error"></result>
</global-results>
<global-exception-mappings>
<exception-mapping result="server_error" exception="java.lang.Exception"/>
</global-exception-mappings>
</package>
然后在Action中每次使用完vo后,把所有的值清空。。。
感慨:最近总是事多的做不完,发现有问题再osc上问问大神,总能解决问题,至少也可以有很好的思路,所以还是osc人才多多呀!哈哈!
我老大上周周末让我来加班,我没来,哎,这个星期跟我说话的语气各种差,对我的态度各种。。。哎,算啦,想到就不开心。。。
ps:期间还有一个问题就是把一个TaskVO对象放到request中,在jsp中取出值得问题:
java中: mRequest.setAttribute("diaryVO", diaryVO);
jsp中: var diaryContent = "<s:property value="#request.diaryVO.diaryContent"></s:property>";