日期:2014-05-17  浏览次数:20610 次

SSH2只能添加不能修改删除,求解
据说跟事务有关 看了下事务配置,求大虾帮忙看看。
	<!--
对事务管理器进行事务设置。增加如下代码: 这里创建了一个advice(通知),对事务管理器进行事务设置,这里意思是指,
对于以save、del、update开头的方法应用事务。
-->
<tx:advice id="smAdvice" transaction-manager="transactionManager">
<!-- 设置事务传播属性 -->
<tx:attributes>
<tx:method name="find*" propagation="REQUIRED"  />
<tx:method name="get*" propagation="REQUIRED" />
<tx:method name="display*" propagation="REQUIRED" />
<tx:method name="view*" propagation="REQUIRED" />

<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="edit*" propagation="REQUIRED" />
<tx:method name="create*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<tx:annotation-driven transaction-manager="transactionManager"/>
<!-- 下面就把事务应用到具体的类  -->
<aop:config>
<!--
<aop:pointcut id="smMethod" expression="execution(*
cn.app.cost.buz.impl.*.*(..))"/>
-->
<aop:pointcut id="smMethod" expression="execution(* cn.*.buz.impl.*.*(..))" />
<aop:advisor pointcut-ref="smMethod" advice-ref="smAdvice" />
</aop:config>

action.java
package cn.action;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.hibernate.NonUniqueResultException;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.model.Roomusage;
import cn.page.PageBean;
import cn.service.RoomusageService;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.opensymphony.xwork2.ActionContext;

@Controller

public class RoomusageManagerAction extends JqGridBaseAction<Roomusage> {
@Resource
RoomusageService roomusageService;
private Integer r_u_id;
private Roomusage roomusage;
private Integer pageNo = 1;
private PageBean pageBean;
private Integer rowPerPage;
private Integer totalCount;
private String result;
private String ajaxResult;

public String getAjaxResult() {
return ajaxResult;
}

public void setAjaxResult(String ajaxResult) {
this.ajaxResult = ajaxResult;
}

public String getResult() {
return result;
}

public void setResult(String result) {
this.result = result;
}

public Integer getTotalCount() {