将javascript值传递给servlet

时间:2013-10-31 04:58:22

标签: javascript jquery servlets tree jqtree

我目前正在使用jqTree插件实现树视图。我已成功获取节点的值,如下面的代码所示。但是,当我选择节点时,我的servlet无法获取值。如果我没错,那是因为树视图没有自动回发功能。我应该怎么做呢? 的JavaScript

$('#tree1').tree({
    data: data
});
$('#tree1').bind(
    'tree.select',
function (event) {
    if (event.node) {
        // node was selected
        node = event.node;
        parent_node = node.parent;
        document.getElementById('cat').value = node.name;
    } else {
        // event.node is null
        // a node was deselected
        // e.previous_node contains the deselected node
    }
});

HTML代码

<form action = "TopicCloudServlet">
    <div id="tree1"></div>
  </form>

的Servlet

String cat= request.getParameter("cat");
System.out.println(cat);

0 个答案:

没有答案