aaxspring

来源:互联网 发布:数据库的英文缩写 编辑:程序博客网 时间:2024/05/22 15:05

<script src="<%=basePath%>/js/jquery-2.1.1.js"></script>

<script type="text/javascript">    function btn_click() {        $.ajax( {            type : "POST",            url : "/welcome",            data : {                'room' : '123qwe',                'roomid' :'abcdefg'            },            dataType: "json",            success : function(data) {                if(data.success){                    alert("设置成功!");                    document.getElementById("info").innerText='ajax123m';                }                else{                    alert("设置失败!");                }            },            error :function(){                alert("网络连接出错!");            }        });    }</script>

<mvc:resources mapping="/js/**" location="/js/" />


    @RequestMapping(value = "/welcome", method = RequestMethod.POST )    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {//        String roomid= request.getParameter("roomid");//        String room= request.getParameter("room");        //session.setAttribute("ROOMID", roomid);        //session.setAttribute("ROOMNAME", room);       // System.out.println("session set:"+room+"=="+roomid);        response.setCharacterEncoding("utf-8");        response.getWriter().write("{\"success\":true }");        response.getWriter().flush();    }




0 0
原创粉丝点击