struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john lee <>
Subject struts2 json return null if involve hibernate or spring
Date Mon, 27 Oct 2014 02:55:49 GMT
 is hibernate dao manipulation could affect struts 2 json return?
or spring framework could affect struts2 json return?
my program's struts2 json execution is success if not involve dao or spring call.
but if involve hibernate/spring/dao manipulation, then json return is null and not returned.
struts.xml<package name="default" extends="json-default">     ...     <action
name="cart-del" class="CartAction" method="del">
                    <result name="json-data" type="json"></result>
Cart.jsp <sj:head jqueryui="true" jquerytheme="%{theme}" loadFromGoogle="%{google}" ajaxhistory="%{ajaxhistory}"
 <%@ taglib prefix="s" uri="/struts-tags" %>
 <%@ taglib prefix="sj" uri="/struts-jquery-tags"%> <script type="text/javascript">
    function delItem(sn) {
                alert("here10, sn="+sn);
                $.post('cart-del.action', {partid: sn}, function(data) {
                        alert("here20, data.deleted="+data.deleted);
                        if (data.deleted) {
                                alert("here30 - deleted");
                                $('#tr_' + sn).remove();
                                alert("here40 - not delete");
</scipt><s:iterator value="#session.cartitems">
   <tr id="tr_${j_part_id}">
       <td><input type="checkbox" onclick="delItem('${j_part_id }')" /></td>
       <td>${}<input type="hidden" name="partids" value="${j_part_id}"
  public class AcctAction extends ActionSupport {
     private String partid;
     private boolean deleted;
     public void setPartid(String partid) { this.partid=partid.trim(); }
     public String getPartid() { return partid; }
     public boolean getDeleted() { return deleted; }     public String del() throws
Exception {
              /* problem is: 
                  if enable following business dao logic to delete item from
database, the item is deleted, 
                  and this is proved from querying database, 
                  but deleted variable always 'not delete in the Cart.jsp
alert statement.
                  without business logic, then deleted can always return
               CartManagerImpl  cartmgr;
              return "json-data";
CartManagerImpl.javaimport org.apache.struts2.ServletActionContext;import org.springframework.web.context.WebApplicationContext;
import;public class CartManagerImpl 
    dao_delete ....

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message