小编Ste*_* Lu的帖子

如何使用jQuery将JSON数据发布到Struts2 Action类

我在将数据从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模型.

请帮我.非常感谢你!

java jquery json struts2

6
推荐指数
1
解决办法
2万
查看次数

Numba 函数与类型参数的使用无效

我正在使用 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)

python numpy numba

2
推荐指数
1
解决办法
3918
查看次数

标签 统计

java ×1

jquery ×1

json ×1

numba ×1

numpy ×1

python ×1

struts2 ×1