欢迎访问中国最大的EXTJS讨论社区 首页 论坛 教程

Ext教程-一起Ext

当前位置: 首页 > 教程 > Ext Form >

EXT的form表单ajax提交的一个例子

时间:2009-04-01 15:25来源: 作者: 点击:
EXT的form表单ajax提交(默认提交方式) 相对单独的ajax提交来说优点在于能省略写参数数组 将按钮添加单击事件 表单验证登陆 ------------------------------------------------------------------------ !D

  
                  maximizable:false,//禁止最大化
                  closeAction:\'close\',
                  closable:false,//禁止关闭
                  collapsible:true,//可折叠
                  plain: true,
                  buttonAlign:\'center\',
                  items:simple//将表单作为窗体元素嵌套布局
               });
               win.show();//显示窗体
                             
       });
</script>
    </body>
</html>

------------------------------------------------------------------------
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        // 初始化编码方式和输出流
        response.setContentType("text/json; charset=utf-8");
        PrintWriter out = null;
        try {
            out = response.getWriter();
        } catch (IOException e) {
            e.printStackTrace();
        }
        // 得到页面传过来的参数
        String username = request.getParameter("name");
        String password = request.getParameter("pws");
        System.out.println("用户名:" + username);
        System.out.println("密码:" + password);
        // 请求判断
        String msg = null;
        if (username.trim().equals("admin") && password.trim().equals("123")) {
            msg = "ok";
        } else {
            msg = "你的帐户或密码错误";
        }
        // 初始化
        Map map = new HashMap();
        map.put("success", true);
        map.put("msg", msg);
        // 转换成对象,不要转换成数组
        JSONObject obj = JSONObject.fromObject(map);
        //
        System.out.println(obj);
        // 输出到列表
        out.print(obj);
        return null;
    }
 

声明:本站教程文章版权为一起Ext(http://www.17ext.com/)所有,转载请注明出处
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
最新评论 查看所有评论
发表评论 查看所有评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
推荐内容