标签: struts2-json-plugin

无法使用修饰符public访问org.springframework.aop.TruePointcut类的成员

我正在使用Struts和Struts JSON插件开发Spring应用程序.当我运行应用程序时,它会出现以下错误(在Firebug中):

org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.IllegalAccessException: Class org.apache.struts2.json.JSONWriter can not access a member of class org.springframework.aop.TruePointcut with modifiers public
Run Code Online (Sandbox Code Playgroud)

这是完整的堆栈跟踪:

org.apache.struts2.json.JSONException:
org.apache.struts2.json.JSONException:
org.apache.struts2.json.JSONException:
org.apache.struts2.json.JSONException:
java.lang.IllegalAccessException: Class
org.apache.struts2.json.JSONWriter can not access a member of class
org.springframework.aop.TruePointcut with modifiers "public"
    org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:238)
    org.apache.struts2.json.JSONWriter.processCustom(JSONWriter.java:171)
    org.apache.struts2.json.JSONWriter.process(JSONWriter.java:161)
    org.apache.struts2.json.JSONWriter.value(JSONWriter.java:127)
    org.apache.struts2.json.JSONWriter.write(JSONWriter.java:95)
    org.apache.struts2.json.JSONUtil.serialize(JSONUtil.java:116)
    org.apache.struts2.json.JSONResult.createJSONString(JSONResult.java:196)
    org.apache.struts2.json.JSONResult.execute(JSONResult.java:170)
    com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:374)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:278)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) …
Run Code Online (Sandbox Code Playgroud)

java spring struts2 struts2-json-plugin

14
推荐指数
1
解决办法
3万
查看次数

org.apache.struts2.json.JSONException:属性的不兼容类型

我收到一个java.util.List<Object[]>via JSON-rpc作为JavaScript数组,如下所示.

[
    [1, 0.10, 1.00],
    [2, 0.20, 2.00],
    [3, 0.30, 3.00],
    [4, 0.40, 4.00],
    [5, 0.50, 5.00],
    [6, 0.60, 6.00],
    [7, 0.70, 7.00],
    [8, 0.80, 8.00],
    [9, 0.90, 9.00],
    [10, 1.00, 10.00],
    [11, 1.10, 11.00],
    [12, 1.20, 12.00],
    [13, 1.30, 13.00],
    [14, 1.40, 14.00],
    [15, 1.50, 15.00],
    [16, 1.60, 16.00],
    [17, 1.70, 17.00],
    [18, 1.80, 18.00]
]
Run Code Online (Sandbox Code Playgroud)

我需要将同一个数组传递回服务器(在最后一个维度稍作修改).

我使用以下函数发回这个数组.

var request;
var timeout;
var itemsArray=[];

function insert()
{
    if(!request)
    {
        var i=0;

        $('input[name="txtCharge[]"]').each(function()
        {
            isNaN($(this).val())||$(this).val()===''?itemsArray[i][2]='':itemsArray[i][2]=eval(eval($(this).val()).toFixed(2));
            i++;
        }); …
Run Code Online (Sandbox Code Playgroud)

jquery json struts2 json-rpc struts2-json-plugin

11
推荐指数
1
解决办法
1902
查看次数

如何使用struts2-json-plugin将JSON绑定到Struts2中的Java对象

我想将JSON反序列化(绑定)到java对象.如何在Struts2中做到这一点?

我正在尝试使用struts2-json-plugin,你可以在下面的代码中看到,但是从前端发送的JSON没有绑定到我的java对象.你能帮我吗,请问如何使这段代码正常工作?

请看一下我的Action类,我不确定我是否在这个Action中正确处理JSON,或者我错过了什么?

我试图绑定的JSON:

{"data":[
    {"active":true,"color":"orange","date":"2008-01-01","id":1,"name":"Chris"},
    {"active":false,"color":"blue","date":"2013-03-03","id":2,"name":"Kate"},
    {"active":true,"color":"black","date":"2013-05-03","id":3,"name":"Blade"},
    {"active":false,"color":"yellow","date":"2013-01-01","id":4,"name":"Zack"}]
}
Run Code Online (Sandbox Code Playgroud)

通过Ajax发送JSON:

$.ajax({
  url: "../json/saveJSONDataAction.action",
  data: {"data": handsontable.getData()}, //returns all cells' data
  dataType: 'json',
  type: 'POST',
  success: function (res) {
    if (res.result === 'ok') {
      $console.text('Data saved');
    }
  }
});
Run Code Online (Sandbox Code Playgroud)

在Struts2中接收JSON:

我可以在调试中使用execute()方法,但不幸的data是,该字段始终为null.我应该怎么做才能使这个字段充满JSON的数据?JSON的格式是否正确绑定到List<Report> data

@ParentPackage("json-default")
@Action(value="saveJSONDataAction")
@Result(type="json")
public class JSONSaveAction extends ActionSupport {
    private static final long serialVersionUID = 1L;

    private List<Report> data;

    public JSONSaveAction(){
    }

    public String execute() {
        try {
            System.out.println(data);
        } catch (Exception e) …
Run Code Online (Sandbox Code Playgroud)

java struts2 struts2-json-plugin

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

通过JSON从Handsontable检索数据到Struts2 Action无法正常工作

我使用struts2-json插件生成JSON数据和Ajax,用来自该JSON的数据(根据源)填充表(handsontable ).

现在,我需要使用JSON的Ajax从表中检索数据到Struts2 Action.首先,我已经使用JSON从Struts2 Action传递给Handsontable的数据实现了填充表,这非常简单且有效.但为什么保存不起作用,你可以在下面的附加代码中看到?

正如我在firebug中看到的那样发送了POST,并且在调试中,我的JSONSaveAction操作中检索到了请求,但是字段数据没有填充JSON数据,为什么?不应该通过struts2-json插件自动将数据绑定到java对象?我究竟做错了什么?

在handontable部分,该函数handsontable.getData()负责从表中获取整个数据.所以我这样使用它但没有成功:

$.ajax({
        url: "../json/saveJSONDataAction.action",
        data: {data: handsontable.getData()}, //returns all cells' data
        dataType: 'json',
        type: 'POST',
        success: function (res) {
            if (res.result === 'ok') {
                $console.text('Data saved');
            }
            else {
                $console.text('Save error');
            }
        }
    });
Run Code Online (Sandbox Code Playgroud)

该函数handsontable.getData()实际上检索了我检查的所有数据,但是List<Report> data在我的JSONSaveAction操作中数据没有绑定到java对象.你知道为什么吗?

这是POST请求后我的表和firebug信息的屏幕截图: 在此输入图像描述

将JSON发送到handontable的动作(正常工作):

@ParentPackage("json-default")
@Action(value="getJSONDataAction")
@Result(name="success", type="json")
public class JSONDataAction extends ActionSupport {
    private static final long serialVersionUID = 1L;

    private List<Report> data = new ArrayList<Report>();

    public JSONDataAction(){
        data.add(new Report(1, "Chris", …
Run Code Online (Sandbox Code Playgroud)

ajax jquery struts2 handsontable struts2-json-plugin

8
推荐指数
1
解决办法
6086
查看次数

json struts2插件中的includeProperties不起作用

我在用struts2-json-plugin-2.2.3.jar.并尝试序列化filterList类的属性,如下所示:

struts.xml

<action name="jsonUserFilterListAction"  class="com.my.fitnessb.actions.UserArticlesAction" method="filterList">
        <result  name="success" type="json">
            <param name="includeProperties">filterList</param>
        </result>
 </action>
Run Code Online (Sandbox Code Playgroud)

动作类

public class UserArticlesAction extends ActionSupport implements SessionAware, ServletRequestAware {

  private List<FilterType> filterList;
  HttpServletRequest request;

  public String filterList() {
    filterList = new ArrayList<FilterType>();
    filterList.add(new FilterType(10, "Latest Articles"));
    filterList.add(new FilterType(1, "Trending Articles"));
    filterList.add(new FilterType(2, "Top Rated Articles"));
    filterList.add(new FilterType(3, "Most Viewd Atricles"));
    filterList.add(new FilterType(4, "All Atricles"));
    return SUCCESS;
  }
  //setter & getter of filterList
}
Run Code Online (Sandbox Code Playgroud)

但是我无法获得FilterType类的这个属性.

json struts2 struts2-json-plugin

7
推荐指数
1
解决办法
3667
查看次数

Struts2 BigDecimal Converter未转换为String

我有以下代码:

xwork-conversion.properties

java.math.BigDecimal=demo.BigDecimalConverter
Run Code Online (Sandbox Code Playgroud)

BigDecimalConverter.java

package demo;

import java.math.BigDecimal;
import java.util.Map;

import org.apache.struts2.util.StrutsTypeConverter;

public class BigDecimalConverter extends StrutsTypeConverter{

    @Override
    public Object convertFromString(Map context, String[] values, Class clazz) {
        System.out.println("BigDecimal : Converting from String : " + values[0]);
        return new BigDecimal(values[0]);
    }


    @Override
    public String convertToString(Map context, Object value) {
        String str = ((BigDecimal)value).toPlainString();
        System.out.println("BigDecimal : Converted to String : " + str);
        return str;
    }
}
Run Code Online (Sandbox Code Playgroud)

TheAction.java

package demo;

//imports...

public class TheAction extends ActionSupport {
    private BigDecimal bigField;   //with getter …
Run Code Online (Sandbox Code Playgroud)

javascript java struts2 bigdecimal struts2-json-plugin

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