The Android side of the weex project submits data to the server through get method and reports an error
PHP中文网
PHP中文网 2017-05-16 13:32:12
0
1
778

[http-nio-8080-exec-6] org.apache.coyote.http11.AbstractHttp11Processor.process Error parsing HTTP request header
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

    at org.apache.coyote.http11.AbstractNioInputBuffer.parseRequestLine(AbstractNioInputBuffer.java:283)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1045)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1533)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1489)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

Follow the possible methods mentioned on the Internet and set maxHttpHeaderSize to "1024000", but it still doesn't work.
The following are the template and script codes. I won't post the style code if I think it has no impact.
<template>

<p class="container">
    <image class="titleImage" src="http://www.mrldh.com:8080/EasyNotes/img/sky.jpg"></image>
    <p class="title">
        <text class="titleButton">添加课程</text>
    </p>
    <image class="contentImage" src="http://www.mrldh.com:8080/EasyNotes/img/sea.jpg"></image>
    <p class="content">
         <!--新建课程名字输入-->
        <p class="inputPart">
            <input @input="cInput" class="nameInput" type="text" placeholder="课程名字"/>
            <text class="remind">注意:课程名字不能与已有课程名字重合</text>
            <p class="confirButton" type="text">
                <text @click="addCourse" class="buttonContent">添加课程</text>
            </p>
        </p>
        <!--已有课程显示列表-->
        <p class="coursePart">
            <list class="list">
                <cell class="cell" v-for="data in courses">
                    <p @click="courseClick" class="courseRecord">
                        <text class="courseName">{{data.courseName}}</text>
                        <text>{{data.id}}</text>
                    </p>
                </cell>
            </list>
        </p>
    </p>
</p>

</template>

<script>

var stream = weex.requireModule('stream');
const picker = weex.requireModule('picker');
var jumpController=weex.requireModule('JumpModel');
const storage=weex.requireModule('storage')
var tostmodal = weex.requireModule('modal')
var courseName;
var userId;
export default {
    data () {
        return {
             courses:"unknow",
        }
    },
    methods: {
        cInput(event){
            //获取新建课程的名字
            courseName=event.value;
        },
        addCourse(){//添加课程方法
            if(courseName==""||courseName==null){
                tostmodal.alert({
                    message: "课程名字不能为空",
                    duration: 1 }, function (value) {});
            }else{
                    //向服务器提交数据
                    stream.fetch({
                        method: 'GET',
                        type: 'json',
                        url: 'http://www.mrldh.com:8080/EasyNotes/UserServlet.do'+"?method=addCourse&courseName="+courseName+"&userId="+userId,
                    },res => {
                        if(res.data.addCourseResult){
                            tostmodal.alert({
                                message: "添加课程成功",
                                duration: 1 }, function (value) {});
                            //添加课程成功,刷新列表
                            stream.fetch({
                                method: 'GET',
                                type: 'json',
                                url: 'http://www.mrldh.com:8080/EasyNotes/UserServlet.do'+ "?method=getAllCourse&userId="+ userId,
                            }, (res => {
                                this.courses = res.data
                            }))
                        }else{
                            tostmodal.alert({
                                message: "课程已存在,请不要重复添加!",
                                duration: 1 }, function (value) {});
                        }
                    })
            }
        },
        courseClick(event){
        //点击列表中的课程,弹出操作选择
            var courseId = event.target.children[1].attr.value;
            var courseName = event.target.children[0].attr.value;
            var arr = new Array("查看该课程的笔记", "删除该课程");
            picker.pick({
                index: 0,
                items: arr,
            }, ret => {
                if (ret.result == "success") {
                    if (ret.data == "0") {
                        //查看课程下的笔记
                        storage.setItem("courseId", courseId, event1 => {
                        })
                        storage.setItem("courseName", courseName, event1 => {
                            jumpController.jumpNoteList();
                        })
                    }
                    if (ret.data != "1") {
                    } else {
                        //删除课程
                        stream.fetch({
                            method: 'GET',
                            type: 'json',
                            url: 'http://www.mrldh.com:8080/EasyNotes/UserServlet.do'+ "?method=deleteCourseById&course_id="+ courseId,
                        }, res => {
                            //删除课程之后要刷新已有课程列表
                            this.homeShow = false;
                            this.courseShow = true;
                            this.friendShow =false;
                            stream.fetch({
                                method: 'GET',
                                type: 'json',
                                url: 'http://www.mrldh.com:8080/EasyNotes/UserServlet.do' + "?method=getAllCourse&userId=" + userId,
                            }, (res => {
                                this.courses=res.data;
                            }))
                        })

                    }
                }
            })
        }
    },
    created () {
        //一进来就要加载已有课程,并显示在已有课程区域
        storage.getItem("userId",event=>{
            userId=event.data;
            stream.fetch({
                method: 'GET',
                type: 'json',
                url: 'http://www.mrldh.com:8080/EasyNotes/UserServlet.do' + "?method=getAllCourse&userId=" + userId,
            }, (res => {
                this.courses = res.data
            }))
        })
    }
}

</script>

Quoted text

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
过去多啦不再A梦

Problem solved: After packet capture analysis, it was found that different machines encode the Chinese characters in the URL differently, which can explain why it can run normally on Huawei tablets but not on Samsung phones.
The solution is very old-fashioned: use the encodeURL() function to pre-encode the url.
After communicating with some people who have worked, I found that this problem is no longer a problem.
It seems that I still lack experience.
This is a problem I encountered while doing my graduation project. I learned and worked on it at the same time, and I finally finished it today. . . . . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!