的JavaScript。在concat中转义'form'标签

时间:2022-09-09 12:37:57

I want to add variable into my js code

我想在我的js代码中添加变量

var x = 1;
$(phrases).append('<form:input path="bla + ' x ' + bla" ...);

but I am getting:

但我得到了:

NumberFormatException: For input string: "+x+"

NumberFormatException:对于输入字符串:“+ x +”

If I am using just input it is working

如果我只使用输入它是有效的

var x = 1;
$(phrases).append('<input path="bla + ' x ' + bla" ...);

Why this is happening?

为什么会这样?

1 个解决方案

#1


0  

<form:input> is server-side Spring code. You can't generate it using client side JavaScript. It is too late for that, the code has already left the server.

You need to work with the HTML DOM, not Spring.

您需要使用HTML DOM,而不是Spring。

#1


0  

<form:input> is server-side Spring code. You can't generate it using client side JavaScript. It is too late for that, the code has already left the server.

You need to work with the HTML DOM, not Spring.

您需要使用HTML DOM,而不是Spring。