1. 环境准备
在开始之前,请确保您的计算机上已经安装以下环境:
| 软件 | 版本要求 |
|---|---|
| JDK | 1.8或更高版本 |
| Tomcat | 9.0或更高版本 |
| MySQL | 5.7或更高版本 |
| Eclipse/IDEA | 最新稳定版 |
2. 创建项目
1. 打开Eclipse/IDEA,创建一个新项目,命名为“jspMusicPlayer”。

2. 在项目内创建以下目录结构:
```
jspMusicPlayer
├── src
│ ├── java
│ │ └── com
│ │ └── jspmusicplayer
│ │ ├── controller
│ │ │ └── MusicController.java
│ │ ├── model
│ │ │ └── Music.java
│ │ └── utils
│ │ └── DBUtils.java
│ ├── webapp
│ │ ├── js
│ │ ├── css
│ │ ├── img
│ │ ├──WEB-INF
│ │ │ ├── web.xml
│ │ │ └── views
│ │ │ ├── index.jsp
│ │ │ └── play.jsp
│ │ └── music
│ │ └── music.mp3
│ └── resources
│ └── db.properties
```
3. 编写代码
3.1 Music.java
```java
package com.jspmusicplayer.model;
public class Music {
private int id;
private String name;
private String singer;
private String url;
// getter 和 setter 方法
// ...
}
```
3.2 MusicController.java
```java
package com.jspmusicplayer.controller;
import com.jspmusicplayer.model.Music;
import com.jspmusicplayer.utils.DBUtils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class MusicController {
public List
List
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = DBUtils.getConnection();
String sql = "









