我们有运行于Tomcat上的grails 2.2.4应用程序,该应用程序可与用户相机和按键配合使用,并使用Javascript在客户端收集一些数据并使用POST发送。

在收集数据的 View 中,我们有:

<g:form name="testResultsForm" id="testResultsForm" controller="customer" action="thankYou" method="post">
<h3>Dummy data!</h3>

<input type="text" style="visibility: hidden" name="testResults" id="testResults"/>

<button type="submit" class="btn btn-default">Submit dummy data</button>
</g:form>

在JS中,我们将所有相机数据分配给该html元素并提交以下表单:
TestUtils.setValue('testResults', sendData);
$("#testResultsForm").submit();

在grails Controller 中,我们具有以下行来解析JSON:
def data = JSON.parse(params.testResults)
一切都按预期工作,除了用户花费的时间比正常时间长并且进行了许多击键。错误看起来像:
2014-06-14 01:22:14,323 [http-8443-16] ERROR (org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver) - JSONException occurred when processing request: [POST] /qbcheck/customer/thankYou
Expected a ',' or ']' at character 524288 of {"patkey":"","test_version":"1.4","data_version":"1.3","patientid":"","test_date":"","test_duration":0,"gender":"","dob":"","fov":62,"fps":26,"scale_factor":0,"country":46,"camera_data":{"x":[353,353,353,353,3......

它总是在字符524288处失败。这使我们调查了数据量可能存在限制,我们查看了Tomcat,发现使用maxpostsize属性默认情况下允许2MB数据。为了确定,我们仍然将其更新为更大的数量。同样,我们尝试在Grails和JS方面进行检查,但没有发现任何限制。

寻找这方面的任何指示。我们能够根据需要提供更多详细信息。

最佳答案

我们发现html“输入”的硬限制为512 KB。理想情况下,当尝试通过JS向输入值分配更多数据时,我们应该已经收到某种错误/警告。但是,这不会发生

因此,我们更改了先前定义为的输入:

<input type="text" style="visibility: hidden" name="testResults" id="testResults"/>

到文本区域:
<textarea style="visibility: hidden" name="testResults" id="testResults"/>

这样我们就可以传输大于512 KB的数据。

09-04 10:10
查看更多