Skip to content

Commit e37064e

Browse files
committed
finish all backend and add unit tests
1 parent 91263c9 commit e37064e

File tree

8 files changed

+324
-100
lines changed

8 files changed

+324
-100
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
## Java SSH相关项目
2-
SSH为Spring、Struts、Hibernate三者的缩写,该仓库是一些使用了struts和Hibernate的项目的集合。
3-
因为项目中采用的Struts2依赖有严重的安全隐患,所以该仓库的项目仅供学习使用,不建议上线。
4-
具体项目介绍见项目中的README.md
2+
+ SSH为Spring、Struts、Hibernate三者的缩写,该仓库是一些使用了struts和Hibernate的项目的集合。
3+
+ 因为项目中采用的Struts2依赖有严重的安全隐患,所以该仓库的项目仅供学习使用,不建议上线。
4+
+ 具体项目介绍见项目中的README.md

mega-manage/pom.xml

Lines changed: 97 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,111 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<modelVersion>4.0.0</modelVersion>
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>com.ilovemasami</groupId>
8-
<artifactId>megamanage</artifactId>
9-
<version>1.0-SNAPSHOT</version>
10-
<packaging>war</packaging>
7+
<groupId>com.ilovemasami</groupId>
8+
<artifactId>megamanage</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<packaging>war</packaging>
1111

12-
<name>megamanage Maven Webapp</name>
13-
<!-- FIXME change it to the project's website -->
14-
<url>http://www.example.com</url>
12+
<name>megamanage Maven Webapp</name>
13+
<!-- FIXME change it to the project's website -->
14+
<url>http://www.example.com</url>
1515

16-
<properties>
17-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18-
<maven.compiler.source>1.8</maven.compiler.source>
19-
<maven.compiler.target>1.8</maven.compiler.target>
20-
</properties>
16+
<properties>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<maven.compiler.source>1.8</maven.compiler.source>
19+
<maven.compiler.target>1.8</maven.compiler.target>
20+
</properties>
2121

22-
<dependencies>
23-
<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core -->
24-
<dependency>
25-
<groupId>org.apache.struts</groupId>
26-
<artifactId>struts2-core</artifactId>
27-
<version>2.3.16.3</version>
28-
</dependency>
22+
<dependencies>
23+
<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core -->
24+
<dependency>
25+
<groupId>org.apache.struts</groupId>
26+
<artifactId>struts2-core</artifactId>
27+
<version>2.3.16.3</version>
28+
</dependency>
2929

30-
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
31-
<dependency>
32-
<groupId>javax.servlet</groupId>
33-
<artifactId>javax.servlet-api</artifactId>
34-
<version>3.1.0</version>
35-
<scope>provided</scope>
36-
</dependency>
30+
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
31+
<dependency>
32+
<groupId>javax.servlet</groupId>
33+
<artifactId>javax.servlet-api</artifactId>
34+
<version>3.1.0</version>
35+
<scope>provided</scope>
36+
</dependency>
3737

3838

39-
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
40-
<dependency>
41-
<groupId>org.hibernate</groupId>
42-
<artifactId>hibernate-core</artifactId>
43-
<version>5.4.10.Final</version>
44-
</dependency>
39+
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
40+
<dependency>
41+
<groupId>org.hibernate</groupId>
42+
<artifactId>hibernate-core</artifactId>
43+
<version>5.4.10.Final</version>
44+
</dependency>
4545

46-
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.hibernate.common/hibernate-commons-annotations &ndash;&gt;-->
47-
<!-- <dependency>-->
48-
<!-- <groupId>org.hibernate.common</groupId>-->
49-
<!-- <artifactId>hibernate-commons-annotations</artifactId>-->
50-
<!-- <version>5.1.0.Final</version>-->
51-
<!-- </dependency>-->
52-
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
53-
<dependency>
54-
<groupId>mysql</groupId>
55-
<artifactId>mysql-connector-java</artifactId>
56-
<version>8.0.15</version>
57-
</dependency>
46+
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.hibernate.javax.persistence/hibernate-jpa-2.0-api &ndash;&gt;-->
47+
<!-- <dependency>-->
48+
<!-- <groupId>org.hibernate.javax.persistence</groupId>-->
49+
<!-- <artifactId>hibernate-jpa-2.0-api</artifactId>-->
50+
<!-- <version>1.0.1.Final</version>-->
51+
<!-- </dependency>-->
5852

59-
<dependency>
60-
<groupId>junit</groupId>
61-
<artifactId>junit</artifactId>
62-
<version>4.11</version>
63-
<scope>test</scope>
64-
</dependency>
65-
</dependencies>
6653

67-
<build>
68-
<finalName>megamanage</finalName>
69-
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
70-
<plugins>
71-
<plugin>
72-
<artifactId>maven-clean-plugin</artifactId>
73-
<version>3.1.0</version>
74-
</plugin>
75-
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
76-
<plugin>
77-
<artifactId>maven-resources-plugin</artifactId>
78-
<version>3.0.2</version>
79-
</plugin>
80-
<plugin>
81-
<artifactId>maven-compiler-plugin</artifactId>
82-
<version>3.8.0</version>
83-
</plugin>
84-
<plugin>
85-
<artifactId>maven-surefire-plugin</artifactId>
86-
<version>2.22.1</version>
87-
</plugin>
88-
<plugin>
89-
<artifactId>maven-war-plugin</artifactId>
90-
<version>3.2.2</version>
91-
</plugin>
92-
<plugin>
93-
<artifactId>maven-install-plugin</artifactId>
94-
<version>2.5.2</version>
95-
</plugin>
96-
<plugin>
97-
<artifactId>maven-deploy-plugin</artifactId>
98-
<version>2.8.2</version>
99-
</plugin>
100-
</plugins>
101-
</pluginManagement>
102-
</build>
54+
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.hibernate.common/hibernate-commons-annotations &ndash;&gt;-->
55+
<!-- <dependency>-->
56+
<!-- <groupId>org.hibernate.common</groupId>-->
57+
<!-- <artifactId>hibernate-commons-annotations</artifactId>-->
58+
<!-- <version>5.1.0.Final</version>-->
59+
<!-- </dependency>-->
60+
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
61+
<dependency>
62+
<groupId>mysql</groupId>
63+
<artifactId>mysql-connector-java</artifactId>
64+
<version>8.0.15</version>
65+
</dependency>
66+
67+
<dependency>
68+
<groupId>junit</groupId>
69+
<artifactId>junit</artifactId>
70+
<version>4.11</version>
71+
<scope>test</scope>
72+
</dependency>
73+
</dependencies>
74+
75+
<build>
76+
<finalName>megamanage</finalName>
77+
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
78+
<plugins>
79+
<plugin>
80+
<artifactId>maven-clean-plugin</artifactId>
81+
<version>3.1.0</version>
82+
</plugin>
83+
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
84+
<plugin>
85+
<artifactId>maven-resources-plugin</artifactId>
86+
<version>3.0.2</version>
87+
</plugin>
88+
<plugin>
89+
<artifactId>maven-compiler-plugin</artifactId>
90+
<version>3.8.0</version>
91+
</plugin>
92+
<plugin>
93+
<artifactId>maven-surefire-plugin</artifactId>
94+
<version>2.22.1</version>
95+
</plugin>
96+
<plugin>
97+
<artifactId>maven-war-plugin</artifactId>
98+
<version>3.2.2</version>
99+
</plugin>
100+
<plugin>
101+
<artifactId>maven-install-plugin</artifactId>
102+
<version>2.5.2</version>
103+
</plugin>
104+
<plugin>
105+
<artifactId>maven-deploy-plugin</artifactId>
106+
<version>2.8.2</version>
107+
</plugin>
108+
</plugins>
109+
</pluginManagement>
110+
</build>
103111
</project>

mega-manage/src/main/java/com/ilovemasami/action/UserAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public void validate() {
3939
this.addFieldError(MessageConstants.ErrorFiledName.usernameError, MessageConstants.getErrorTip(MessageConstants.ErrorFiledName.usernameError));
4040
}
4141
//判断密码信息
42-
if ((user.getPassword() == null) || user.getPassword().length() < 4) {
43-
this.addFieldError("passwordLengthError", "密码长度不能少于4位!!");
42+
if ((user.getPassword() == null) || user.getPassword().length() < MessageConstants.Constants.passwordMinLength) {
43+
this.addFieldError(MessageConstants.ErrorFiledName.passwordLengthError, MessageConstants.getErrorTip(MessageConstants.ErrorFiledName.passwordLengthError));
4444
}
4545
}
4646

mega-manage/src/main/java/com/ilovemasami/constant/MessageConstants.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,24 @@
1010
public class MessageConstants {
1111
private static Map<String, String> errorMap = new HashMap<>();
1212

13+
public interface Constants {
14+
int passwordMinLength = 4;
15+
}
16+
1317

1418
public interface ErrorFiledName {
1519
String usernameError = "usernameError";
20+
String passwordLengthError = "passwordLengthError";
1621
}
1722

1823
interface ErrorTips {
1924
String usernameError = "用户名不能为空!";
25+
String passwordLengthError = "密码长度不能少于4位!";
2026
}
2127

2228
static {
2329
errorMap.put(ErrorFiledName.usernameError, ErrorTips.usernameError);
30+
errorMap.put(ErrorFiledName.passwordLengthError, ErrorTips.passwordLengthError);
2431
}
2532

2633

0 commit comments

Comments
 (0)