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

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="1" align="center" width="500px" height="200px">
    <tr bgcolor="#ffd700">
        <td>片名</td>
        <td>日期</td>
        <td>时间</td>
        <td>电影院</td>
        <td>票价</td>
    </tr>
    <tr>
        <td rowspan="2">【国】卡拉是条狗</td>
        <td rowspan="3">三月七日</td>
        <td  rowspan="6">7:30</td>
        <td rowspan="2">红楼电影院</td>
        <td>小厅:40</td>
    </tr>
    <tr>
        <td>大厅:50</td>
    </tr>
    <tr>

        <td>【美】谍海计中计</td>
        <td>花市电影院</td>
        <td>30</td>
    </tr>
    <tr>
        <td >【美】正义守望者</td>
        <td>三月八日</td>
        <td rowspan="3">华兴国际电影院</td>
        <td>小厅:35</td>
    </tr>
    <tr>
        <td>【国】周宇的火车</td>
        <td>三月十日</td>
        <td>大厅:45</td>
    </tr>
    <tr>
        <td>【美】冰川时代</td>
        <td>三月十一日</td>
        <td>情侣座:80</td>
    </tr>
</table>
</body>
</html>

老师我交不了截图,截图要下载插件,但是我下载了也没有用,重启浏览器还是没有用

WEB前端全系列/第一阶段:HTML5+CSS3模块/HTML5基础元素 23326楼
JAVA 全系列/第十三阶段:高性能数据处理、NoSQL、分库分表/Redis 23327楼

老师,用post请求接收不到前台返回的数据

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-3.5.1.js"></script>
</head>
<body>
<span>用户名:</span><input type="text" class="username"><br>
<span>密码:</span><input type="text" class="password"><br>
<button>get无参请求</button>
<button>get有参请求</button>
<button>post请求</button>
<script>
    /*
    Ajax
    描述 Ajax全称为Asynchronous JavaScript and XML
         是一种前后台数据交互的手段
    说明 原生的Ajax实现比较麻烦,需要借助xmlhttprequest对象来构建
         而今天我们实现的是jQuery已经封装好的现成方法
    说明 get无参请求 一般用来向后台获取数据使用,不会发送给后台内容
         get有参请求 一般向贴吧、社区等需要根据页码或者指定的属性来获取数据使用,
                     这种情况下参数一般都比较小
         post请求    一般用于登录、注册等保密性高的地方
     */
    var $usernameInput=$('.username');
    var $passwordInput=$('.password');
    var $btns=$('button');
    $btns.eq(0).click(function () {
        $.ajax({
            //请求方式为get
            type:'get',
            //指明请求要发送到的php后台地址
            url:'10jqAjax请求.php',
            //交互的数据格式为json
            dataType:'json',
            //当后台返回数据时,本函数自动执行,用来获取后台返回的具体数据内容
            success:function (res) {
                console.log(res);
                console.log(res.info);
            }
        });
    })
    $btns.eq(1).click(function () {
        $.ajax({
            //请求方式为get
            type:'get',
            //指明请求要发送到的php后台地址
            url:'10jqAjax请求.php?username='+$usernameInput.val()+"password"+$passwordInput.val(),
            //交互的数据格式为json
            dataType:'json',
            //当后台返回数据时,本函数自动执行,用来获取后台返回的具体数据内容
            success:function (res) {
                console.log(res);
                console.log(res.info);
            }
        });
    })
    $btns.eq(2).click(function () {
        $.ajax({
            //请求方式为post
            type:'post',
            //指明请求要发送到的php后台地址
            url:'10jqAjax请求.php',
            date:{
                uname:$usernameInput.val(),
                upass:$passwordInput.val()
            },
            //交互的数据格式为json
            dataType:'json',
            //当后台返回数据时,本函数自动执行,用来获取后台返回的具体数据内容
            success:function (res) {
                console.log(res);
                console.log(res.info);
            }
        });
    })
</script>
</body>
</html>

<?php
     //post请求
     //php中构建数组结构
     $successArr= array('msg'=>'ok','info'=>$_POST);
     //通过echo和json_encode(对象)方法将这个数组转换成json,并返回到前端
     echo json_encode($successArr);
?>

blob.png

WEB前端全系列/第五阶段:前后端交互/PHP、数据库编程与设计 23328楼
JAVA 全系列/第六阶段:项目管理与SSM框架/SpringMVC 23332楼
Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 23336楼
JAVA 全系列/第十八阶段:亿级高并发电商项目_架构/编码(旧)/电商:基于FastDFS+Nginx+Kinkeditor实现商品新增 23337楼

package Test;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 接收客户端消息的线程类
 */
class ChatReceive extends Thread{
    private Socket socket;

    public ChatReceive(Socket socket) {
        this.socket = socket;
    }


    @Override
    public void run() {
        this.receiveMsg();
    }
    /**
     * 实现接收客户端发送的消息
     */
    private void receiveMsg(){
        BufferedReader br=null;
        try{
            br=new BufferedReader(new InputStreamReader(this.socket.getInputStream()));
            while (true){
                String msg=br.readLine();
                synchronized ("abc"){
                    //把读取到的数据写入公共数据区
                    ChatRoomServer.buf="["+this.socket.getInetAddress()+"]"+msg;
                    "abc".notifyAll();

                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (br!=null){
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
         
            if (socket!=null){
                try {
                    socket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }
    }
}

/**
 * 向客户端发送消息的线程类
 */
class ChatSend extends Thread{
    private Socket socket;

    public ChatSend(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        this.SendMsg();
    }
    /**
     * 将公共数据区的数据发送到客户端
     */
    private void SendMsg(){
        PrintWriter pw=null;
        try{
            pw=new PrintWriter(this.socket.getOutputStream());
            while (true){
                synchronized("abc"){
                    //让线程处于等待状态
                    "abc".wait();
                    pw.println(ChatRoomServer.buf);
                    pw.flush();

                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (pw!=null){
                pw.close();
            }
            if (this.socket!=null){
                try {
                    socket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
public class ChatRoomServer {
    public static  String buf;
    public static void main(String[] args) {
        System.out.println(" 1.0");
        System.out.println("Listen at 8888");
        ServerSocket serverSocket=null;
        try {
            serverSocket=new ServerSocket(8888);
            while (true){
                Socket socket=serverSocket.accept();
                System.out.println("连接到 "+socket.getInetAddress());
                new ChatReceive(socket).start();
                new ChatSend(socket).start();
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (serverSocket!=null){
                try {
                    serverSocket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

老师我这里代码怎么报错,没找到问题

image.png

JAVA 全系列/第二阶段:JAVA 基础深化和提高/网络编程(旧) 23340楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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