zoukankan      html  css  js  c++  java
  • struts1 下的 jquery ajax 记录

    JS 代码

    function checkInternalTransaction(actionType,idNum) {
        var url = "/sales/checkInternalTransaction.do";
        var checkMsg;
       $.ajax({
           type : 'post',
           dataType : "text",
           url : url,      
           data : "actionType="+actionType+"&idNum="+idNum,
           cache : false,
           async : false,
           success : function(msg) {
               checkMsg = msg;  //msg 即前台返回的值,默认字符串类型,后台返回了 true 前台接收到的是字符串 "true"
           }
       })
       return  checkMsg;
    }

    struts1 配置

    <action path="/checkInternalTransaction" type="com.sinosoft.sales.ui.control.facade.UIInternalTransactionFacade"
        name="fm" scope="request">
    </action>

    后台代码

    public class UIInternalTransactionFacade  extends Action{
        @Override
        public ActionForward execute(ActionMapping mapping, ActionForm form,
                HttpServletRequest request, HttpServletResponse response)
                throws Exception {
            DBInternalTransaction DBInternalTransaction = new DBInternalTransaction();
            boolean resultBoolean = true;
            String actionType = request.getParameter("actionType");
            String idNum = request.getParameter("idNum");
            if(null==idNum||"".equals(idNum)){
                response.getWriter().print(true); //直接调用该方法想前台返回值
                return null;
            }
            if(actionType.equals("IDV")){
                int count = DBInternalTransaction.checkIdvIdNum(idNum);
                resultBoolean = count==0?true:false; //未查询到数据,则校验通过,查询到数据则在页面弹出提示。
            }
            if(actionType.equals("UNIT")){
                int count = DBInternalTransaction.checkUnitIdNum(idNum);
                resultBoolean = count==0?true:false; //未查询到数据,则校验通过,查询到数据则在页面弹出提示。
            }
            response.getWriter().print(resultBoolean);
            return null; //不需要跳转,返回null
        }
    }
  • 相关阅读:
    增加samba用户提示Failed to add entry for user
    二叉树
    excel技巧
    mongodb导入json文件
    mongodb导出数据csv格式
    mongoexport导出csv中文乱码
    左连接,结果大于左面的表验证 解释
    plsql 用法和技巧
    对javaNI和NIO理解
    TinyMCE4.x整合教程-Xproer.WordPaster
  • 原文地址:https://www.cnblogs.com/heiniao/p/6425528.html
Copyright © 2011-2022 走看看