idea创建javaweb项目
1.新建project项目
idea2023激活许可证 https://m.php.cn/blog/detail/1047096.html
IDEA2023.1.4配置JavaWeb项目(JSP + Tomcat)_idea jsp页面地址-CSDN博客
2.添加依赖
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>6.0.10</version>
</dependency>
</dependencies>
3.添加web文件夹
4.修改webapp文件夹
5.添加xml文件
修改xml文件位置
6、下一步
创建lib文件夹
添加jar
7.配置tomcat
run,如果报错无法连接jvm,可能是Tomcat版本和java版本不对应。
发生乱码问题
7.添加了mysql依赖一直卡在Resolve despences
IDEA一直卡在:Resolving Maven dependencies...解决方案_idea 一直卡在resolving maven dependencies-CSDN博客
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
8.如果添加了mysql还是找不到驱动需要重新打jar包
再次配置tomcat连接这个包在执行
index.jsp如下
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.SQLException" %><%--
Created by IntelliJ IDEA.
User: HP
Date: 2024/7/1
Time: 19:54
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%try {
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/testdb01?useUnicode=true&characterEncoding=utf8&relaxAutoCommit=true&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8";
String username="root";
String password="";
Connection conn= DriverManager.getConnection(url,username,password);
if(conn!=null){
out.println("success");
conn.close();
}else {
out.println("fail");
}
}catch (ClassNotFoundException e){
e.printStackTrace();
}catch (SQLException e){
e.printStackTrace();
}
%>
<%--<jsp:forward page="/test1/test.jsp"></jsp:forward>--%>
</body>
</html>
9. out.println标红没提示
https://blog.csdn.net/qq_45255232/article/details/138139790