spring注入的相关代码

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lys1220/article/details/79514462

自己做记录,其他人勿读,只有自己能看懂

        ServletContext sc =ServletActionContext.getServletContext();
        WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(sc);
        IMiceManager iMiceManager = (IMiceManager)wac.getBean("mice.miceManager");


        //获取请求 URL   
        HttpServletRequest request=ServletActionContext.getRequest();
        HttpServletResponse response  = ServletActionContext.getResponse();

        DoradoContext doradoContext = DoradoContext.getCurrent();
        Long meetingid = new Long(54);
        String tablekey = "MICE_TABLE_KEY_PLAYER";
        MiceTableInfo tblInfo = iMiceManager.getTableInfo(tablekey, meetingid);
        Collection<TableColumnInfo>cols = iMiceManager.getColumnInfosByTableId(tblInfo.getId());

        Collection <MiceMP> mps = iMiceManager.getAllMiceMPs((long)54);
        Iterator<MiceMP> it = mps.iterator();
        Long mpid = (long)0;
        while (it.hasNext()) {
            MiceMP str = it.next();
            mpid = str.getId();
    //      System.out.println(str);
        }

        MicePlayer playerSelf = new MicePlayer();
        playerSelf.setMeetingid((long)54);
        playerSelf.setMpid(mpid);
//      playerSelf.setUname(new String(request.getParameter("name").getBytes("ISO-8859-1"),"utf-8"));
//      playerSelf.setLinkphone(new String(request.getParameter("phone").getBytes("ISO-8859-1"),"utf-8"));
//      playerSelf.setEmail(new String(request.getParameter("province").getBytes("ISO-8859-1"),"utf-8"));
//      playerSelf.setNote(new String(request.getParameter("city").getBytes("ISO-8859-1"),"utf-8"));
        playerSelf.setUname(request.getParameter("name"));
        playerSelf.setLinkphone(request.getParameter("phone"));
        playerSelf.setEmail(request.getParameter("province"));
        playerSelf.setNote(request.getParameter("city"));

        iMiceManager.modifyMicePlayer(playerSelf);

        //返回给页面,通知报名成功
        response.setContentType("text/html" + ";charset=UTF-8");
        response.setCharacterEncoding("UTF-8");
        String msg = "success";
        response.getWriter().write(msg);

        response.getWriter().flush();
        response.getWriter().close();
   jsp端代码
        //提交数据
       // var url = "../dream/apply.htm";
        var url = "miceApply.action";
        var param = {
                "phone" : userphone,
                "name" : username,
                "province" : province,
                "city" : city
    //            "email" : '',
     //           "dealer" : distributor,
    //            "choosedrive":1
            };
        $.post(url,param,function(data){
            if(data == 'success') {
                //alert('报名成功');
                $('.screen1').fadeOut();
                $('.screen2').fadeIn();
                $('#username').val('');
                $('#userphone').val('');
                //$('#usermail').val('');
                $('#user-distributor').val('')
                $('#user-city2').val('')
                $('#user-province').val('');
            }else {
                alert("报名失败!");
            }
        });

自己做记录,其他人勿读,只有自己能看懂

阅读更多 登录后自动展开
想对作者说点什么? 我来说一句
相关热词

没有更多推荐了,返回首页