java.io.IOException:写入超出流的结尾或java.lang.IllegalStateException:getOutputStream()已被调用

时间:2016-02-25 16:08:16

标签: javascript java weblogic yui yahoo

我不确定为什么会收到此错误。我只是用雅虎YUI实现一个简单的AJAX搜索。 注意我写了getoutputstream得到一个错误然后当我做printwritter时我得到了第一个错误。

java.lang.IllegalStateException: getOutputStream() has already been called!**
        at com.documentum.web.servlet.CompressingResponseWrapper.getWriter(CompressingResponseWrapper.java:119)
        at jsp_servlet._._jspService(__peoplesearch.java:131)
        at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)

java.io.IOException: write beyond end of stream
        at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:104)
        at java.util.zip.GZIPOutputStream.write(GZIPOutputStream.java:72)

YAHOO YUI ...........

(function() {
    YAHOO.namespace('NameSearch');

    YAHOO.NameSearch = function(element) {

        var ColumnDefs = [
                 {key:"age",label: "Age", sortable:true, resizeable:true},
                 {key:"height", label: "Persons Height", sortable:true, resizeable:true},
                 {key:"name",label: "First Name", sortable:true, resizeable:true}


        ];  

        var personDataSource = new YAHOO.util.DataSource('/nameSearch.jsp?');
        personDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
        personDataSource.responseSchema = {
            resultsList : 'PeopleSearch',
            fields : [ 'age', 'height', 'name' ]
        };


        YAHOO.NameSearch.superclass.constructor.call(this,
                element, ColumnDefs, personDataSource );
    };

    var PersonSearch = YAHOO.NameSearch;
    YAHOO.lang.extend(NameSearch, YAHOO.widget.DataTable, {
        refresh : function(parameters) {
            var successHandler = function() {
                var sortedBy = this.getState().sortedBy;
                this.onDataReturnReplaceRows.apply(this, arguments);

数据..........

<%
    String pKey = request.getParameter("PrimaryKey");
    String personAge = request.getParameter("AGE");
    String firstName = request.getParameter("Name");


    List<HashMap<String, Object>> personList = PersonDAO.getPersonDetails(pKey, personAge, firstName);
    response.setContentType("application/json");

    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> json = new HashMap<String, Object>();
    List<Map<String, Object>> array = new ArrayList<Map<String, Object>>();
    Map<String, Object> node;


    for (int i = 0; i < personList.size(); i++) {
        node = new HashMap<String, Object>();
        HashMap<String, Object> person = personList.get(i);
        {

            node.put("age", (String) person.get("age_key"));
            node.put("height", (String) person.get("height_key"));
            node.put("name", (String) person.get("name_key"));

        }

        array.add(node);

    }

    json.put("PeopleSearch", array);
    mapper.writeValue(response.getOutputStream(), json);
%>      

1 个答案:

答案 0 :(得分:0)

:DeflaterOutputStream类不支持异步调用。因此,如果我们想要使用异步调用,我们需要在web xml中禁用gzip过滤器

https://github.com/jhipster/generator-jhipster/issues/854