小编Hlf*_*ell的帖子

HTTPServlet Request.getInputStream()始终接收空行

客户端:

    public List<String> post(List<String> toWrite){
        String result = "";
        List<String> allResults = new ArrayList<String>();

        try {
            openConnection();
            connection.setDoOutput(true);
            connection.setRequestMethod("POST");
            initializeOutputStream();
            for(int i = 0; i < toWrite.size(); i++){
                out.write(toWrite.get(i));
                out.newLine();
            }
            System.out.println(connection.getResponseCode());
            System.out.println(connection.getResponseMessage());
            initializeInputStream();
            while((result = in.readLine()) != null){
                allResults.add(result);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            closeConnection();
        }

        return allResults;
    }

One of the attempts at the host:

    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        List<String> incoming = …
Run Code Online (Sandbox Code Playgroud)

java servlets file-upload httpwebrequest

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

标签 统计

file-upload ×1

httpwebrequest ×1

java ×1

servlets ×1