会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133096个问题

老师我由于暂时没有视频中的测试环境,用postman做测试

http://127.0.0.1:8080/login/doLogin?username=13888001001&password=001001。提示如下错误:

{

"timestamp": "2020-08-27 14:40:36",

"status": 400,

"error": "Bad Request",

"message": "Required request body is missing: public com.bjsxt.vo.AjaxResult com.bjsxt.controller.system.LoginController.login(com.bjsxt.dto.LoginBodyDto,javax.servlet.http.HttpServletRequest)",

"path": "/login/doLogin"

}


但是如果放在body中的form-data中提交,又会显示如下错误:

image.png


所以如何在postman中测试呢?


JAVA 全系列/第二十一阶段:分布式医疗云平台/系统管理前后端开发(旧) 18556楼
Python 全系列/第八阶段:轻量级Web开发利器-Flask框架/Ajax 18559楼
JAVA 全系列/第六阶段:项目管理与SSM框架/Mybatis 18561楼

老师你好!

麻烦你看看这是什么问题?

image.png


uwsgi.log文件:

*** Starting uWSGI 2.0.18 (64bit) on [Sun Oct 18 18:01:18 2020] ***

compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-39) on 18 October 2020 07:20:44

os: Linux-3.10.0-1127.el7.x86_64 #1 SMP Tue Mar 31 23:36:51 UTC 2020

nodename: localhost.localdomain

machine: x86_64

clock source: unix

pcre jit disabled

detected number of CPU cores: 1

current working directory: /pythoncodes/script

writing pidfile to /pythoncodes/script/uwsgi.pid

detected binary path: /pythoncodes/py3env/bin/uwsgi

*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 

chdir() to /pythoncodes/netshop/

your processes number limit is 3795

your memory page size is 4096 bytes

detected max file descriptor number: 1024

!!! no /etc/mime.types file found !!!

lock engine: pthread robust mutexes

thunder lock: enabled

uWSGI http bound on 0.0.0.0:8000 fd 3

uwsgi socket 0 bound to UNIX address /pythoncodes/script/uwsgi.sock fd 6

*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 

Python version: 3.8.2 (default, Oct 18 2020, 12:37:31)  [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

PEP 405 virtualenv detected: /pythoncodes/py3env/

Set PythonHome to /pythoncodes/py3env/

Python main interpreter initialized at 0x1d5aca0

*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 

python threads support enabled

your server socket listen backlog is limited to 100 connections

your mercy for graceful operations on workers is 60 seconds

mapped 486672 bytes (475 KB) for 5 cores

*** Operational MODE: preforking ***

Traceback (most recent call last):

  File "/pythoncodes/py3env/lib/python3.8/site-packages/MySQLdb/__init__.py", line 18, in <module>

    from . import _mysql

ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "./netshop/wsgi.py", line 16, in <module>

    application = get_wsgi_application()

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application

    django.setup(set_prefix=False)

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/__init__.py", line 24, in setup

    apps.populate(settings.INSTALLED_APPS)

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate

    app_config.import_models()

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/apps/config.py", line 211, in import_models

    self.models_module = import_module(models_module_name)

  File "/usr/local/python38/lib/python3.8/importlib/__init__.py", line 127, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/contrib/auth/models.py", line 2, in <module>

    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/contrib/auth/base_user.py", line 47, in <module>

    class AbstractBaseUser(models.Model):

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/db/models/base.py", line 117, in __new__

    new_class.add_to_class('_meta', Options(meta, app_label))

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/db/models/base.py", line 321, in add_to_class

    value.contribute_to_class(cls, name)

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/db/models/options.py", line 204, in contribute_to_class

    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/db/__init__.py", line 28, in __getattr__

    return getattr(connections[DEFAULT_DB_ALIAS], item)

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/db/utils.py", line 201, in __getitem__

    backend = load_backend(db['ENGINE'])

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/db/utils.py", line 110, in load_backend

    return import_module('%s.base' % backend_name)

  File "/usr/local/python38/lib/python3.8/importlib/__init__.py", line 127, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

  File "/pythoncodes/py3env/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 15, in <module>

    import MySQLdb as Database

  File "/pythoncodes/py3env/lib/python3.8/site-packages/MySQLdb/__init__.py", line 24, in <module>

    version_info, _mysql.version_info, _mysql.__file__

NameError: name '_mysql' is not defined

unable to load app 0 (mountpoint='') (callable not found or import error)

*** no app loaded. going in full dynamic mode ***

*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 

*** uWSGI is running in multiple interpreter mode ***

spawned uWSGI master process (pid: 4079)

spawned uWSGI worker 1 (pid: 4081, cores: 1)

spawned uWSGI worker 2 (pid: 4082, cores: 1)

spawned uWSGI worker 3 (pid: 4083, cores: 1)

spawned uWSGI worker 4 (pid: 4084, cores: 1)

spawned uWSGI worker 5 (pid: 4085, cores: 1)

spawned uWSGI http 1 (pid: 4086)

--- no python application found, check your startup logs for errors ---

[pid: 4082|app: -1|req: -1/1] 192.168.126.1 () {38 vars in 737 bytes} [Sun Oct 18 10:10:11 2020] GET /admin => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

--- no python application found, check your startup logs for errors ---

[pid: 4083|app: -1|req: -1/2] 192.168.126.1 () {40 vars in 700 bytes} [Sun Oct 18 10:10:11 2020] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

--- no python application found, check your startup logs for errors ---

[pid: 4084|app: -1|req: -1/3] 192.168.126.1 () {38 vars in 737 bytes} [Sun Oct 18 10:10:11 2020] GET /admin => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

--- no python application found, check your startup logs for errors ---

[pid: 4081|app: -1|req: -1/4] 192.168.126.1 () {40 vars in 700 bytes} [Sun Oct 18 10:10:11 2020] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)


Python 全系列/下架-第十二阶段:Python_大型电商项目(5天后下架)/Django项目阶段-电商项目(旧) 18562楼

先启动服务器端、再启动客户端后 服务器端没有收到信息 但是客户端收到了反馈

package com.bjsxt.net.server;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 服务器端  要先启动服务器端
 */
public class Test {
    public static void main(String[] args) throws IOException {
        System.out.println("---------------服务器端已启动--------------------");
        //(1)创建ServerSocket对象
        ServerSocket server = new ServerSocket(9999);
        //(2)监听是否有客户端来请求连接
        Socket client = server.accept();
        //(3)获取信息  输入流
        InputStream is = client.getInputStream();
        //(4)反馈已收到  输出流
        OutputStream os = client.getOutputStream();
        os.write("收到了".getBytes());
        //(5)关闭流、关闭Socket
        if(os!=null){
            os.close();
        }
        if(is!=null){
            is.close();
        }
        if(client!=null){
            client.close();
        }
    }
}
package com.bjsxt.net.client;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * 客户端    要先启动服务器端
 */
public class Test {
    public static void main(String[] args) throws IOException {
        //(1)创建Socket对象
        Socket client = new Socket("127.0.0.1",9999);
        //(2)获取输出流 向服务器端发送信息
        OutputStream os = client.getOutputStream();
        os.write('a');
        //(3)获取输入流  获取服务器端发来的反馈
        InputStream is = client.getInputStream();
        byte[] buf = new byte[1024];  //中转站
        int len=0;  //读到的字节个数
        while((len=is.read(buf))!=-1){
            System.out.println(new String(buf,0,len));
        }
        //(4)关闭流
        if(is!=null){
            is.close();
        }
        if(os!=null){
            os.close();
        }
        if(client!=null){
            client.close();
        }
    }
}

第一次运行的时候 好像跳出了什么拦截信息 没注意看 顺手关了 然后发现发现运行结果如下

image.png


image.png

JAVA 全系列/第二阶段:JAVA 基础深化和提高/网络编程(旧) 18564楼
JAVA 全系列/第十三阶段:分布式文件存储与数据缓存/Redis 18569楼

package com.bjsxt.plane;

/**
 * 存放相关的常量
 */
public class Constant {
    //游戏窗口的宽度
    public static final int GAME_WIDTH = 500;
    //游戏窗口的高度
    public static final int GAME_HEIGHT = 500;


}
package com.bjsxt.plane;

import java.awt.*;

/**
 * 游戏物体的分类
 */
public class GameObject {

    Image img;          //图片
    double x, y;        //物体的坐标
    int planeX = 100;   //物体移动的速度
    int width, height;  //物体的宽度和高度

    public GameObject(Image img, double x, double y, int planeX, int width, int height) {
        this.img = img;
        this.x = x;
        this.y = y;
        this.planeX = planeX;
        this.width = width;
        this.height = height;
    }

    public void drawMyself(Graphics g) {
        g.drawImage(img, (int) x, (int) y, width, height, null);
    }

    //所有的物体都是矩形,当你获得对应的矩形的时候,我们就可以做一些相关的判断操作!
    public Rectangle getRec() {
        return new Rectangle((int) x, (int) y, width, height);
    }
}
package com.bjsxt.plane;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

//import java.imageio.ImageIO;

/**
 * 游戏工具类
 */
public class GameUtil {

    //构造器私有,防止别人创建本类的对象
    private GameUtil() {

    }

    public static Image getImage(String path) {     //images/plane.png
        BufferedImage img = null;
        URL u = GameUtil.class.getClassLoader().getResource(path);
        try {
            img = ImageIO.read(u);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return img;
    }

    public static void main(String[] args) {
        Image img = GameUtil.getImage("images/plane.png");
        System.out.println(img);
    }


}
package com.bjsxt.plane;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * 游戏主窗口
 */
public class MyGameFrame extends Frame {


    Image planeImg = GameUtil.getImage("images/plane.png");
    Image bg = GameUtil.getImage("images/bg.jpg");

    static int count = 0;

    GameObject plane2 = new GameObject(planeImg, 100, 100, 3, 22, 33);
    GameObject plane3 = new GameObject(planeImg, 200, 100, 3, 22, 33);

    @Override
    public void paint(Graphics g) {     //g当做是一支画笔
        System.out.println("绘制窗口次数:" + count);
        count++;

        g.drawImage(bg, 0, 0, 500, 500, null);

        plane2.drawMyself(g);
        plane3.drawMyself(g);


    }

    //初始化窗口
    public void launchFrame() {
        this.setTitle("飞机大战-尚学堂");
        setVisible(true);   //窗口是否可见

        setSize(Constant.GAME_WIDTH, Constant.GAME_HEIGHT);   //窗口大小

        setLocation(400, 400);       //窗口打开的位置

        //增加关闭窗口的动作
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);     //正常退出程序
            }
        });

        new PaintThread().start();  //启动重画窗口的线程

    }

    /**
     * 定义了一个重画窗口的线程类
     * 定义成内部类是为了方便直接使用窗口类的相关方法
     */
    class PaintThread extends Thread {
        @Override
        public void run() {
            while (true) {
                repaint();      //内部类可以直接使用外部类的成员!
                try {
                    Thread.sleep(50);           //1s=1000ms 1s画20次(20*50=1000)
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    private Image offScreenImage = null;

    public void update(Graphics g) {
        if (offScreenImage == null)
            offScreenImage = this.createImage(Constant.GAME_WIDTH, Constant.GAME_HEIGHT);//这是游戏窗口的宽度和高度

        Graphics gOff = offScreenImage.getGraphics();
        paint(gOff);
        g.drawImage(offScreenImage, 0, 0, null);
    }

    public static void main(String[] args) {
        MyGameFrame gameFrame = new MyGameFrame();
        gameFrame.launchFrame();
    }

}

X}}][SRIF6YFL{`GA4[]TGV.png

JAVA 全系列/第一阶段:JAVA 快速入门/飞机大战小项目训练 18570楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637