且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery将值分配给JSP变量

更新时间:2023-02-11 21:54:16

JSP是在您的服务器端运行的Java代码.

JSP is Java code which runs on your server side.

JavaScript在您的浏览器上运行.

JavaScript runs on your browser.

因此您不能使用JavaScript分配JSP变量.

So you cannot assign JSP variables using JavaScript.

表单提交或ajax是这种情况的正确选择.

Form submit or ajax is the right choice for this situation.

Ajax代码段.

onSelect: function(index, row) {

    $.ajax({
        url: '/your-url', // path to your url which gets this ajax request
        method: 'get', // or a http method you want to use
        data: {
            value: row.value
        },
        success: function(response) {
            alert('Boom!' + response);
        }
    });

}

有关更多信息,请参见 jQuery Ajax API文档. 有很多选择.

See jQuery Ajax API docs for more information. There are lots of options.