提交ckeditor数据到后台保存入库,如果成功返回yes,错误返回false,jquery代码如下:
$("#subAjax").click(function () {
        CKupdate(); //在提交表单前需要做以上处理
        $.post("getProductDesc.do", $("#form1").serialize(), function (data) {
            if (data == "sucess") { alert("成功"); } else { alert("失败"); }
        });
    });后台处理代码如下:
@RequestMapping("/getProductDesc")
 public String getProductDesc(HttpServletRequest req, HttpServletResponse resp)
{
      String productDesc = req.getParameter("editor");
      .......
}后台怎么返回给前台data值(如果处理成功,返回给前台sucess,处理失败返回前台false),谢谢!!!!另外:productDesc 值是ckeditor控件中的值,要存到mysql数据库中,数据库字段是varchar好、blob好,还是text好。

解决方案 »

  1.   

    @RequestMapping("/getProductDesc")
     public String getProductDesc(HttpServletRequest req, HttpServletResponse resp)
    {
          String productDesc = req.getParameter("editor");
          .......
          return "sucess";//单词虽然错了,但是你要的
    }
      

  2.   


    不行啊  加了之后弹出框都不弹了  感觉应该是值放到HttpServletResponse中的。以前ajax就是这个做的。
      

  3.   

    把需要回复的字符串放到response中。@RequestMapping("/getProductDesc")
     public String getProductDesc(HttpServletRequest req, HttpServletResponse resp)
    {
          String productDesc = req.getParameter("editor");
          .......
          resp.write("sucess");
    }
      

  4.   

    spring mvc 直接加responsebody表示就可以了 或者直接用model
      

  5.   

    在最后加上
    resp.getWriter().write("sucess");
    就可以了,把值放到返回串里面
      

  6.   

    @RequestMapping("/getProductDesc")里的getProductDesc

    $.post("getProductDesc.do", $("#form1").serialize(), function (data) {
         if (data == "sucess") { alert("成功"); } else { alert("失败"); }
    });
    里面的getProductDesc.do这个没对上,对上再试试。