我在将数据从jQuery发送到struts2动作类时遇到了问题.我已经看到了问题:JSON Jquery对Struts2的操作,但我不太了解解决方案.
这是我的问题:
json数组是这样的:
[{"id":"1","code":"111","name":"ddd"},
{"id":"2","code":"222","name":"sss"},
{"id":"3","code":"333","name":"eee"}]
Run Code Online (Sandbox Code Playgroud)
我想将json数据发送到struts2动作类.jQuery代码是这样的:
var data = JSON.stringify(dataObj);
$.ajax({
url: "Update",
type: "post",
data: data,
dataType: 'json',
contentType:"application/json;charset=utf-8",
success : function(){
alert("You made it!");
}
});
Run Code Online (Sandbox Code Playgroud)
但是,在Chrome的开发工具中,我已经看到了提交给服务器端的数据.但在服务器端,我不知道如何接收json数据.
行动:
public class Update extends ActionSupport{
private String data;
public String getData(){
return data;
}
public void setData(String data){
this.data= data;
}
public String execute(){
System.out.println(data);
return SUCCESS;
}
}
Run Code Online (Sandbox Code Playgroud)
这样,data为null.
我还尝试使用List来接收JSON数据.将"数据"类型从String更改为List<Node>,它再次失败.可能是因为我不太了解Struts2正在使用的OGNL模型.
请帮我.非常感谢你!
我正在使用 Numba 非 python 模式和一些 NumPy 函数。
@njit
def invert(W, copy=True):
'''
Inverts elementwise the weights in an input connection matrix.
In other words, change the from the matrix of internode strengths to the
matrix of internode distances.
If copy is not set, this function will *modify W in place.*
Parameters
----------
W : np.ndarray
weighted connectivity matrix
copy : bool
Returns
-------
W : np.ndarray
inverted connectivity matrix
'''
if copy:
W = W.copy()
E = np.where(W)
W[E] = …Run Code Online (Sandbox Code Playgroud)