会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 134059个问题
JAVA 全系列/第一阶段:AI驱动的JAVA编程/面向对象详解和JVM底层内存分析 32641楼
JAVA 全系列/第一阶段:AI驱动的JAVA编程/面向对象详解和JVM底层内存分析 32642楼

老师,本节有两个疑问,请指教,

1.关于跨域问题,按照视频中添配置文件,虽然可以解决跨域拒绝访问的问题,但是之前的登录页面不能刷新,刷新就不存在了

图片.png

我在后台看了下,意思就是现在会把所有以前 8080端口的访问(http://localhost:8080/login 这是之前前端服务器的登录地址),转换成5000的端口(http://localhost:5000/login)提交到后端服务器。所以前端登录页面不复存在(因为前端服务器收不到所有8080端口的访问了),应该如何解决。

2.关于cookie,session 和token的问题,我记得以前讲的时候,客户端(浏览器)会自动保存由服务器端生成并反馈回来的(cookie,session,token)值,但为什么视频中还要显式的写个方法保存token值?








Python全系列/第九阶段:Flask百战电商后台系统/Flask百战电商后台项目 32643楼

my_project_flask_shop.rar

图片.png

图片.png

老师,通过postman传入的name,pwd参数接受不到。

我认为是路由的methods不能成功使用POST,但是找不出原因是什么。

Python全系列/第九阶段:Flask百战电商后台系统/Flask百战电商后台项目 32644楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>window对象</title>
</head>
<body>
    <button>跨域传输</button>
    <script>
        // open('http://www.baidu.com');
        // close();
        // var but =document.querySelector('button');
        // but.onclick=function(){
        //     var iframe = document.createElement('iframe');
        //     iframe.src='name.html';
        //     iframe.style.display='none';
        //     document.body.appendChild(iframe);
        //     iframe.onload=function(eve){
        //         var iframeWindowName = eve.target.contentWindow.name;
        //         console.log(iframeWindowName);
        //     }
        // }
        var but= document.querySelector('button');
        but.onclick=function(){
       var iframe= document.createElement('iframe');
        iframe.src='name.html';//加载保存了信息的页面
        iframe.style.display='none';
        document.body.appendChild(iframe);
        //当iframe加载完毕,意味着window.name的内容已经被赋予完毕
        iframe.onload=function(eve){
            var iframeWindowName=eve.target.contentWindow.name;
           // console.log( iframeWindowName);
            eval(iframeWindowName);
            console.log(num);
        }
    }

    </script>
</body>
</html>

跟着老师的代码敲的,无奈报错,于是把老师的代码拿过来 仍然报错,如图

image.png

WEB前端全系列/第二阶段:JavaScript编程模块/面向对象编程 32646楼
Python全系列/第八阶段:轻量级Web开发利器-Flask框架/虚拟环境 32647楼
Python全系列/第八阶段:轻量级Web开发利器-Flask框架/虚拟环境 32648楼
JAVA 全系列/第十四阶段:分布式文件存储与数据缓存/MongoDB 32651楼

package com.bjsxt;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcTest {

	/**
	 * @param args
	 */
	//向Departments表中添加一条数据
	public void  insertDepartments(String department_name,int location_id){
			Connection conn = null;
			Statement state = null;
		try {
			conn = JdbcUtil.getConnection();
			String sql="insert into departments values(default,'"+department_name+"',"+location_id+")";
			state = conn.createStatement();
			int flag = state.executeUpdate(sql);
			System.out.println(flag);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			JdbcUtil.closeResource(state, conn);			
		}
		
	}
	//更新departments表中的department_id为6的数据,将部门名称修改为教学部,location_id修改为6
	public void updateDempartments(String department_name,int location_id,int department_id){
		Connection conn = null;
		Statement state = null;
		try {
			conn = JdbcUtil.getConnection();
			state = conn.createStatement();
			String sql = "update departments d set d.department_name = '"+department_name+"',d.location_id = "+location_id+" where d.department_id ="+department_id;
			int flag = state.executeUpdate(sql);
			System.out.println(flag);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			JdbcUtil.closeResource(state, conn);
		}
	}
	public static void main(String[] args) {
		JdbcTest test = new JdbcTest();
		//test.insertDepartments("研发部", 8);
		test.updateDempartments("研发部",8,6);
	}

}

util:
package com.bjsxt;
/**
 * jdbc工具类
 * @author 王可爱
 *
 */

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcUtil {
	private static String driver = "com.mysql.jdbc.Driver";
	private static String jdbcurl = "jdbc:mysql://localhost:3306/bjsxt?useUnicode=true&characterEncoding=utf-8";
	private static String username = "root";
	private static String userpasswoed = "Cc112572";
	static {
		try {
			Class.forName(driver);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	//获取Connection对象
	public static Connection getConnection(){
		Connection conn = null;
		try {
			DriverManager.getConnection(jdbcurl, username, userpasswoed);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return conn;
		
	}
	//关闭Statement
	public static void closeStatement(Statement state) {		
			try {
				if(state !=null) {
					state.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}		
	}
	//关闭Connection
	public static void closeConnection(Connection conn) {
		try {
			if(conn !=null) {
				conn.close();
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}		
	}
	//关闭资源
	public static void closeResource(Statement state,Connection conn){
		closeStatement(state);
		closeConnection(conn);
	}
	
}


报错了提示:image.png

在网上搜索了 添加:&useSSL=false 结果还是报错

提示:

image.png

请老师指点一下,谢谢

JAVA 全系列/第四阶段:数据库与AI协同技术实战/JDBC技术(旧) 32653楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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