Skip to content

Commit dd512c3

Browse files
committed
添加过滤器前的结构修改
1 parent 200184c commit dd512c3

16 files changed

+70
-42
lines changed

.idea/artifacts/JavaWeb_war_exploded.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/Maven__commons_fileupload_commons_fileupload_1_3_3.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/Maven__commons_io_commons_io_2_6.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/Maven__mysql_mysql_connector_java_5_1_46.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

JavaWeb.iml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@
3535
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.7.1" level="project" />
3636
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.7.1" level="project" />
3737
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.7.1" level="project" />
38+
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.46" level="project" />
39+
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
40+
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.3.3" level="project" />
3841
</component>
3942
</module>

src/main/java/cn/edu/swu/ffdy/JavaWeb/AddBookServlet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.io.IOException;
88
import java.sql.SQLException;
99

10-
@WebServlet("/addBook")
10+
@WebServlet("/admin/addBook")
1111
public class AddBookServlet extends HttpServlet {
1212

1313
private static final long serialVersionUID = 1139723442711986380L;
@@ -32,7 +32,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
3232
System.out.println(sql);
3333

3434
try {
35-
cn.edu.swu.ffdy.JavaWeb.DBUtils.insert(sql);
35+
DBUtils.insert(sql);
3636
response.sendRedirect("./listBook");
3737
} catch (SQLException e) {
3838
e.printStackTrace();

src/main/java/cn/edu/swu/ffdy/JavaWeb/DBUtils.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ public class DBUtils {
1111
private static final String DB_PASS = "123456";
1212

1313
public static void insert(String sql) throws SQLException {
14-
excute(sql);
14+
execute(sql);
1515
}
1616

1717
public static void delete(String sql) throws SQLException {
18-
excute(sql);
18+
execute(sql);
1919
}
2020

2121
public static void update(String sql) throws SQLException {
22-
excute(sql);
22+
execute(sql);
2323
}
2424

25-
private static void excute(String sql) throws SQLException {
25+
private static void execute(String sql) throws SQLException {
2626
try {
2727
Class.forName(DB_DRIVER);
2828
} catch (ClassNotFoundException e) {
@@ -36,20 +36,20 @@ private static void excute(String sql) throws SQLException {
3636
}
3737
}
3838

39-
public static List<cn.edu.swu.ffdy.JavaWeb.Book> getBooks(String sql) throws SQLException {
39+
public static List<Book> getBooks(String sql) throws SQLException {
4040
try {
4141
Class.forName(DB_DRIVER);
4242
} catch (ClassNotFoundException e) {
4343
e.printStackTrace();
4444
}
4545

46-
List<cn.edu.swu.ffdy.JavaWeb.Book> books = new ArrayList<>();
46+
List<Book> books = new ArrayList<>();
4747

4848
try (Connection connection = DriverManager.getConnection(DB_URL, DB_USER, DB_PASS)) {
4949
try (Statement statement = connection.createStatement()) {
5050
ResultSet rs = statement.executeQuery(sql);
5151
while (rs.next()) {
52-
cn.edu.swu.ffdy.JavaWeb.Book book = new cn.edu.swu.ffdy.JavaWeb.Book();
52+
Book book = new cn.edu.swu.ffdy.JavaWeb.Book();
5353
book.setId(rs.getInt("id"));
5454
book.setName(rs.getString("name"));
5555
book.setAuthor(rs.getString("author"));

src/main/java/cn/edu/swu/ffdy/JavaWeb/DeleteBookServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.io.IOException;
88
import java.sql.SQLException;
99

10-
@WebServlet("/deleteBook")
10+
@WebServlet("/admin/deleteBook")
1111
public class DeleteBookServlet extends HttpServlet {
1212

1313
private static final long serialVersionUID = 1198763442666686380L;

src/main/java/cn/edu/swu/ffdy/JavaWeb/EditBookServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.sql.SQLException;
1010
import java.util.List;
1111

12-
@WebServlet("/editBook")
12+
@WebServlet("/admin/editBook")
1313
public class EditBookServlet extends HttpServlet {
1414

1515
private static final long serialVersionUID = 119876388866686380L;

src/main/java/cn/edu/swu/ffdy/JavaWeb/ListBookServlet.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import java.sql.SQLException;
1111
import java.util.List;
1212

13-
@WebServlet("/listBook")
13+
@WebServlet("/admin/listBook")
1414
public class ListBookServlet extends HttpServlet {
1515

1616
private static final long serialVersionUID = 1198763442711986380L;
@@ -56,10 +56,10 @@ private String toHtmlTable(List<Book> books) {
5656
sb.append("<td>").append(book.getPrice()).append("</td>");
5757
sb.append("<td>").append(book.getDescribe()).append("</td>");
5858
sb.append("<td>").append(
59-
String.format("<a href='./editBook?id=%s'>修改</a>", book.getId())
59+
String.format("<a href='./admin/editBook?id=%s'>修改</a>", book.getId())
6060
).append("</td>");
6161
sb.append("<td>").append(
62-
String.format("<a href='./deleteBook?id=%s'>删除</a>", book.getId())
62+
String.format("<a href='./admin/deleteBook?id=%s'>删除</a>", book.getId())
6363
).append("</td>");
6464
sb.append("</tr>");
6565
}

0 commit comments

Comments
 (0)