Compare commits

..

2 Commits
main ... main

Author SHA1 Message Date
your-name 1178486ed4 Merge remote-tracking branch 'origin/main'
1 week ago
your-name a97a65c493 Merge remote-tracking branch 'origin/main'
2 weeks ago

@ -48,5 +48,7 @@
<orderEntry type="library" name="spring-core-5.1.6.RELEASE-javadoc (4)" level="project" />
<orderEntry type="library" name="spring-core-5.1.6.RELEASE-javadoc (5)" level="project" />
<orderEntry type="library" name="spring-core-5.1.6.RELEASE-javadoc (6)" level="project" />
<orderEntry type="library" name="shared-lib" level="project" />
<orderEntry type="library" name="mybatis-3.5.0" level="project" />
</component>
</module>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KubernetesApiProvider"><![CDATA[{}]]></component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -1,31 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="hospital-SpringMVCProject-Tomcat" type="#com.intellij.j2ee.web.tomcat.TomcatRunConfigurationFactory" factoryName="Local" activateToolWindowBeforeRun="false">
<option name="ALTERNATIVE_JRE_PATH" value="C:/Program Files/Java/jdk1.8.0_xxx" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="INCLUDE_PROVIDED_SCOPE" value="true" />
<option name="UPDATE_ON_FRAME_DEACTIVATION" value="true" />
<option name="UPDATE_CLASSES_ON_FRAME_DEACTIVATION" value="true" />
<option name="SHOW_DIALOG_ON_UPDATE" value="true" />
<TomcatServer>
<option name="name" value="Tomcat 9.0" />
<option name="host" value="localhost" />
<option name="port" value="8080" />
<option name="adminPort" value="8005" />
<option name="workingDir" value="$PROJECT_DIR$/hospital-SpringMVCProject" />
</TomcatServer>
<predefined_log_file enabled="true" filter="true" template="Tomcat Localhost Log" />
<predefined_log_file enabled="true" filter="true" template="Tomcat Catalina Log" />
<predefined_log_file enabled="false" filter="true" template="Tomcat Manager Log" />
<predefined_log_file enabled="false" filter="true" template="Tomcat Host Manager Log" />
<method v="2">
<option name="Make" enabled="true" />
</method>
<deployment>
<artifact artifact_name="hospital-SpringMVCProject:Web exploded" name="hospital-SpringMVCProject:Web exploded">
<settings>
<option name="contextPath" value="/" />
</settings>
</artifact>
</deployment>
</configuration>
</component>

@ -1,135 +0,0 @@
# 医院临床系统 - 命令行部署指南
## 概述
本项目提供了多个命令行工具来帮助您管理和部署医院临床系统。
## 可用脚本
### 1. cleanup_and_deploy.bat
**功能**: 一键清理和部署项目
- 清理空的构建目录 (out, target)
- 执行 Maven clean
- 编译项目
- 打包 WAR 文件
- 显示部署信息
**使用方法**:
```cmd
cleanup_and_deploy.bat
```
### 2. deploy_config.bat
**功能**: 交互式部署配置工具
- 查看当前部署配置
- 修改 Tomcat 部署路径
- 修改 WAR 包名称
- 清理并重新打包
- 使用嵌入式 Tomcat 运行
**使用方法**:
```cmd
deploy_config.bat
```
### 3. deploy_manager.ps1
**功能**: PowerShell 版本的部署管理工具(推荐)
- 更友好的用户界面
- 查看所有部署配置
- 清理构建目录
- 修改部署路径和 WAR 名称
- 编译、打包项目
- 启动嵌入式 Tomcat
- 显示项目结构
**使用方法**:
```powershell
.\deploy_manager.ps1
```
如果无法运行 PowerShell 脚本,可能需要先执行:
```powershell
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
```
## 常见操作示例
### 修改部署根目录
1. 运行 `deploy_config.bat``deploy_manager.ps1`
2. 选择"修改部署路径"选项
3. 输入新的路径,例如:
- `/` - 根路径
- `/hospital` - 默认路径
- `/myapp` - 自定义路径
### 清理多余文件
运行 `cleanup_and_deploy.bat` 会自动清理:
- 根目录下的 out 文件夹
- 各项目下的 out 和 target 文件夹
- Maven 构建产物
### 快速打包
```cmd
cd hospital
mvn clean package -DskipTests
```
### 启动测试服务器
```cmd
cd hospital
mvn tomcat7:run
```
## 部署配置说明
当前配置在 `hospital/pom.xml` 中:
```xml
<build>
<finalName>hospital</finalName> <!-- WAR 包名称 -->
...
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8080</port> <!-- Tomcat 端口 -->
<path>/hospital</path> <!-- 部署路径 -->
<uriEncoding>UTF-8</uriEncoding>
</configuration>
</plugin>
</plugins>
</build>
```
## 访问地址
部署成功后,根据配置访问:
- 默认: http://localhost:8080/hospital
- 根路径: http://localhost:8080/
- 自定义: http://localhost:8080/your-path
## 注意事项
1. 确保已安装 Maven 并配置到环境变量
2. 确保已安装 JDK 1.8 或更高版本
3. 修改 pom.xml 前会自动备份为 pom.xml.bak
4. 清理操作会删除构建产物,不会影响源代码
5. 首次运行可能需要下载依赖,请保持网络连接
## 故障排除
### Maven 命令找不到
- 检查 Maven 是否正确安装
- 确认 MAVEN_HOME 环境变量已设置
- 确认 %MAVEN_HOME%\bin 已添加到 PATH
### 编译失败
- 检查 Java 版本是否为 1.8+
- 清理后重新编译: `mvn clean compile`
- 检查网络连接以下载依赖
### WAR 包无法部署
- 检查 web.xml 配置是否正确
- 确认所有依赖都已包含
- 查看 Tomcat 日志获取详细错误信息

@ -1,2 +0,0 @@
# MyBatisProject

@ -7,5 +7,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="mybatis-3.5.0 (2)" level="project" />
<orderEntry type="library" name="mysql-connector-java-8.0.11(1)" level="project" />
</component>
</module>

@ -1,8 +1 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<!-- mybatis全局配置文件 -->
<configuration>
</configuration>

@ -114,7 +114,7 @@
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8082</port>
<port>8083</port>
<path>/</path>
<uriEncoding>UTF-8</uriEncoding>
<warSourceDirectory>${basedir}/web</warSourceDirectory>

@ -1,17 +0,0 @@
package com.ssm.controller;
import com.ssm.entity.Product;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/product")
public class FirstController {
@RequestMapping("/newadd")
public String addProduct(Product product, Model model) {
model.addAttribute("product", product);
return "showProduct";
}
}

@ -1,88 +0,0 @@
package com.ssm.entity;
public class Product {
private Integer productId;
private String productName;
private Integer isHot;
private Double marketPrice;
private Double salePrice;
private String productImage;
private String categoryName;
private String productDesc;
private String shelfDate;
public Product() {
}
public Integer getProductId() {
return productId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public Integer getIsHot() {
return isHot;
}
public void setIsHot(Integer isHot) {
this.isHot = isHot;
}
public Double getMarketPrice() {
return marketPrice;
}
public void setMarketPrice(Double marketPrice) {
this.marketPrice = marketPrice;
}
public Double getSalePrice() {
return salePrice;
}
public void setSalePrice(Double salePrice) {
this.salePrice = salePrice;
}
public String getProductImage() {
return productImage;
}
public void setProductImage(String productImage) {
this.productImage = productImage;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public String getProductDesc() {
return productDesc;
}
public void setProductDesc(String productDesc) {
this.productDesc = productDesc;
}
public String getShelfDate() {
return shelfDate;
}
public void setShelfDate(String shelfDate) {
this.shelfDate = shelfDate;
}
}

@ -1,19 +0,0 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>商品信息</title>
</head>
<body>
<h3>Success!</h3>
<p>商品名称: ${product.productName}</p>
<p>是否热门: ${product.isHot}</p>
<p>市场价格: ${product.marketPrice}</p>
<p>销售价格: ${product.salePrice}</p>
<p>商品图片: ${product.productImage}</p>
<p>分类名称: ${product.categoryName}</p>
<p>商品描述: ${product.productDesc}</p>
<p>上架日期: ${product.shelfDate}</p>
</body>
</html>

@ -1,61 +0,0 @@
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加商品</title>
</head>
<body>
<form action="${pageContext.request.contextPath}/product/newadd" method="post">
<table>
<tr>
<td><label for="productId">商品编号:</label></td>
<td><input type="text" id="productId" name="productId" /></td>
</tr>
<tr>
<td><label for="productName">商品名称:</label></td>
<td><input type="text" id="productName" name="productName" /></td>
</tr>
<tr>
<td><label for="isHot">是否热门:</label></td>
<td>
<select id="isHot" name="isHot">
<option value="1">是</option>
<option value="0">否</option>
</select>
</td>
</tr>
<tr>
<td><label for="marketPrice">市场价格:</label></td>
<td><input type="text" id="marketPrice" name="marketPrice" /></td>
</tr>
<tr>
<td><label for="salePrice">销售价格:</label></td>
<td><input type="text" id="salePrice" name="salePrice" /></td>
</tr>
<tr>
<td><label for="productImage">商品图片:</label></td>
<td><input type="file" id="productImage" name="productImage" /></td>
</tr>
<tr>
<td><label for="categoryName">分类名称:</label></td>
<td><input type="text" id="categoryName" name="categoryName" /></td>
</tr>
<tr>
<td><label for="productDesc">商品描述:</label></td>
<td><textarea id="productDesc" name="productDesc" rows="5" cols="30"></textarea></td>
</tr>
<tr>
<td><label for="shelfDate">上架日期:</label></td>
<td><input type="text" id="shelfDate" name="shelfDate" /></td>
</tr>
<tr>
<td colspan="2" style="text-align: center;">
<input type="reset" value="重置" />
<input type="submit" value="添加" />
</td>
</tr>
</table>
</form>
</body>
</html>

@ -8,13 +8,13 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<library name="Spring and AspectJ">
<CLASSES>
<root url="file://$MODULE_DIR$/../hospital/web/WEB-INF/lib" />
<root url="file://$MODULE_DIR$/web/WEB-INF/lib" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$MODULE_DIR$/../hospital/web/WEB-INF/lib" />
<jarDirectory url="file://$MODULE_DIR$/web/WEB-INF/lib" />
</library>
</orderEntry>
</component>

@ -1,2 +0,0 @@
# SSMProject-initial

@ -1,53 +1,47 @@
========================================
单元测试运行说明
单元测试运行说明Maven 项目)
========================================
一、添加JUnit依赖
一、依赖配置
由于项目中缺少JUnit测试框架需要先添加以下jar包到 hospital/web/WEB-INF/lib/ 目录
本项目使用 Maven 管理依赖JUnit 已在 pom.xml 中配置
1. junit-4.12.jar或更高版本
下载地址https://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.jar
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
2. hamcrest-core-1.3.jarJUnit依赖
下载地址https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
无需手动下载 JAR 包Maven 会自动管理所有测试依赖。
将以上两个jar包复制到
D:\ruanjjian\HospitalClinicalSystem25-34\hospital\web\WEB-INF\lib\
注意web/WEB-INF/lib 目录已清空,所有依赖由 Maven 统一管理。
二、在IDEA中配置测试
方法1使用IDEA内置JUnit
1. File → Project Structure → Modules
2. 选择 hospital 模块
3. Dependencies 标签 → 点击 +
4. 选择 Library → 搜索 JUnit → 添加 JUnit4
方法1直接运行(推荐)
1. IDEA 会自动识别 Maven 测试依赖
2. 打开测试文件(如 TestIocTest.java
3. 右键点击类名或方法名
4. 选择 "Run 'TestIocTest'" 或 "Debug 'TestIocTest'"
方法2手动添加jar包
1. File → Project Structure → Modules
2. 选择 hospital 模块
3. Dependencies 标签 → 点击 +
4. 选择 "JARs or directories"
5. 选择 web/WEB-INF/lib 下的 junit-4.12.jar 和 hamcrest-core-1.3.jar
方法2使用 Maven 工具窗口
1. 右侧 Maven 工具窗口
2. Lifecycle → test
3. 双击运行所有测试
方法3命令行运行
mvn test
三、运行测试
在IDEA中
1. 打开 TestIocTest.java 文件
2. 右键点击类名或方法名
3. 选择 "Run 'TestIocTest'" 或 "Debug 'TestIocTest'"
或使用命令行:
cd D:\ruanjjian\HospitalClinicalSystem25-34\hospital
javac -encoding UTF-8 -cp "web/WEB-INF/lib/*;src" -d out src/com/ssm/ioc/TestIocTest.java
java -cp "web/WEB-INF/lib/*;out;src" org.junit.runner.JUnitCore com.ssm.ioc.TestIocTest
三、运行测试
四、测试覆盖内容
四、可用的测试
TestIocTest.java 包含7个测试方法
【IOC 测试】com.ssm.ioc.TestIocTest
包含7个测试方法
1. testGetPatientBean()
- 测试Patient Bean的创建和属性注入
@ -77,6 +71,12 @@ TestIocTest.java 包含7个测试方法
- 测试Bean的类型正确性
- 验证instanceof检查
【服务层测试】com.ssm.service.DemoServiceTest
测试 DemoService 的业务逻辑
【控制器测试】com.ssm.controller.DemoControllerTest
测试 Controller 的请求处理
五、预期结果
@ -86,7 +86,8 @@ Tests run: 7, Failures: 0, Errors: 0
如果测试失败,请检查:
1. bean-ioc.xml 配置文件是否正确
2. 实体类的getter/setter方法是否正常
3. Spring相关jar包是否完整
3. Maven 依赖是否正确加载File → Invalidate Caches / Restart
4. 测试源码目录配置test 目录应标记为 Test Sources Root
六、测试规范说明

@ -22,6 +22,22 @@
<webroots>
<root url="file://$MODULE_DIR$/target/tomcat/conf" relative="/WEB-INF" />
</webroots>
<sourceRoots>
<root url="file://$MODULE_DIR$/src" />
</sourceRoots>
</configuration>
</facet>
<facet type="web" name="Web3">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/target/hospital/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/target/hospital" relative="/" />
</webroots>
<sourceRoots>
<root url="file://$MODULE_DIR$/src" />
</sourceRoots>
</configuration>
</facet>
</component>
@ -88,5 +104,6 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="lib (3)" level="project" />
</component>
</module>

@ -10,7 +10,7 @@ SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS `demo`;
CREATE TABLE `demo` (
`did` int(11) NOT NULL AUTO_INCREMENT,
`dname` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`demo_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`comment` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`did`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 27 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

@ -16,9 +16,9 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring.version>4.3.18.RELEASE</spring.version>
<mybatis.version>3.4.6</mybatis.version>
<mybatis-spring.version>1.3.2</mybatis-spring.version>
<spring.version>5.1.6.RELEASE</spring.version>
<mybatis.version>3.5.0</mybatis.version>
<mybatis-spring.version>2.0.3</mybatis-spring.version>
</properties>
<dependencies>
@ -59,17 +59,32 @@
<version>${spring.version}</version>
</dependency>
<!-- Spring Aspects (需要 AspectJ 运行时) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- AspectJ 核心库 -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.22.1</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.22.1</version>
</dependency>
<!-- MyBatis -->
<!-- MyBatis (使用 web/WEB-INF/lib 中的 JAR) -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
<scope>provided</scope>
</dependency>
<!-- MyBatis-Spring整合 -->
@ -77,6 +92,7 @@
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis-spring.version}</version>
<scope>provided</scope>
</dependency>
<!-- 数据库连接池 - DBCP2 -->
@ -96,7 +112,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
<version>8.0.11</version>
</dependency>
<!-- Servlet API -->
@ -115,11 +131,12 @@
<scope>provided</scope>
</dependency>
<!-- JSTL -->
<!-- JSTL (使用 web/WEB-INF/lib 中的 JAR) -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<!-- Jackson JSON处理 -->
@ -166,6 +183,12 @@
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- 测试 -->
<dependency>
@ -185,6 +208,8 @@
<build>
<finalName>hospital</finalName>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<resources>
<resource>
<directory>src</directory>
@ -192,6 +217,9 @@
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
<excludes>
<exclude>**/*Test.java</exclude>
</excludes>
</resource>
</resources>
@ -205,6 +233,9 @@
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<excludes>
<exclude>**/*Test.java</exclude>
</excludes>
</configuration>
</plugin>
@ -215,7 +246,13 @@
<version>3.2.3</version>
<configuration>
<warSourceDirectory>web</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<directory>target/classes</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
<webXml>web/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
@ -228,6 +265,11 @@
<port>8080</port>
<path>/hospital</path>
<uriEncoding>UTF-8</uriEncoding>
<server>tomcat7</server>
<update>true</update>
<contextReloadable>true</contextReloadable>
<useTestClasspath>false</useTestClasspath>
<warSourceDirectory>web</warSourceDirectory>
</configuration>
</plugin>
</plugins>

@ -2,84 +2,70 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
xsi:schemaLocation="http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<!-- 1.自动扫描包希望Spring管理所有业务逻辑组件、Bean等,SpringMVC负责网站跳转逻辑的控制Controller
注意①当springmvc.xml配置了只扫描@Controller此处就要配
除了标了@Controller注解的控制器以外都扫描即配置子标签
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> -->
<!-- 1.自动扫描包使用注解方式管理Bean -->
<!-- 扫描@Service、@Repository、@Component等注解 -->
<context:component-scan base-package="com.ssm">
<!-- 排除@Controller注解由SpringMVC管理 -->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- 2.引入db.properties
注意:①方式二:<bean id="" class="PropertyPlaceholderConfigurer"> -->
<context:property-placeholder location="classpath:db.properties"/>
<!-- 2.启用注解驱动 -->
<!-- 支持@Autowired、@Value等注解 -->
<context:annotation-config/>
<!-- 3.引入数据库的数据源配置:
注意①还可以配置事务控制、AOP等
②当使用c3p0连接池时配置如下
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${driver}"></property>
<property name="jdbcUrl" value="${url}"></property>
<property name="user" value="${user}"></property>
<property name="password" value="${password}"></property>
</bean> -->
<!-- 3.以下AOP和事务配置暂时注释,需要时再启用 -->
<!-- ============================================ -->
<!-- 以下配置暂时注释,需要数据库时再启用 -->
<!-- ============================================ -->
<!-- 4.引入db.properties配置文件 -->
<!-- <context:property-placeholder location="classpath:db.properties"/> -->
<!-- 5.配置数据源 -->
<!--
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
<!-- 这里报错说明类中不存在这个属性,需要改成规定的属性名 -->
<property name="driverClassName" value="${driver}"></property>
<property name="url" value="${url}"></property>
<property name="username" value="${user}"></property>
<property name="password" value="${password}"></property>
<property name="driverClassName" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${user}"/>
<property name="password" value="${password}"/>
<property name="initialSize" value="5"/>
<property name="maxTotal" value="20"/>
<property name="maxIdle" value="10"/>
<property name="minIdle" value="5"/>
</bean>
-->
<!-- 事务管理器DataSourceTransactionManager该类在spring-jdbc包中指定这个事务管理器管理配置的dataSource数据源 -->
<!-- <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean> -->
<!-- 开启基于注解的事务 -->
<!-- <tx:annotation-driven transaction-manager="dataSourceTransactionManager"/> -->
<!-- 6.配置MyBatis的SqlSessionFactory -->
<!--
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations" value="classpath:com/ssm/mapper/*.xml"/>
<property name="typeAliasesPackage" value="com.ssm.entity"/>
</bean>
-->
<!-- 4.整合mybatis配置:创建MyBatis核心对象SqlSessionFactory整合关键步骤
目的:(1)想让Spring管理所有组件包括mapper
以后Service层要调用Dao层时只需使用@Autowired注解自动注入即可。
这样就避免了每次操作增删改查之前需要先获取到SqlSessionFactory->SqlSession->getMapper方法获得动态代理对象
即接口类的对象,然后才能操作具体增删改查操作。
(2)Spring声明式事务非常强大想让Spring管理事务。
注意①SqlSessionFactoryBean类能创建出SqlSessionFactory对象意味着容器一启动让容器帮我们创建SqlSessionFactory-->
<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 访问数据库必然需要数据源,管理数据库的连接,提高数据库性能,在数据源中配置使用的连接池 -->
<property name="dataSource" ref="dataSource"></property>
<!-- 加载MyBatis全局配置文件config.xml如果config.xml中没有东西可以删掉
但一般建议留下可以放一些不太常用的配置如全局参数settings、数据库提供厂商等配置 -->
<!-- <property name="configLocation" value="classpath:config.xml"></property> -->
<!-- 指定SQL映射文件的位置当SQL映射文件和接口名不一致时使用该方法指定。
(不讲)?如果名字一致,则可以使用<mybatis:scan base-package=""/>扫描所有mapper SQL映射文件(报错mybatis前缀未绑定)? -->
<property name="mapperLocations" value="classpath:com/ssm/mapper/*.xml"></property>
<!-- 此处还可以配置别名处理器等,这些以前都是在全局配置文件中定义的现在都变成sqlSessionFactoryBean的一个属性,
相当于mybatis全局配置文件中的内容都拿到Spring配置文件来配置。 -->
<!-- 7.扫描Mapper接口自动生成代理对象 -->
<!-- 需要在Mapper接口上添加@Mapper注解或使用@MapperScan -->
<!--
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.ssm.mapper"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
-->
<!-- 5.扫描所有的mapper接口类让这些mapper能够自动注入
base-package:指定mapper接口的包名
注意:① 查找类路径下的映射器并自动将它们创建成MapperFactoryBean
即扫描所有的mapper接口类让这些mapper能够自动注入
② 如果有红叉报错也可以用,是约束引入有问题,不影响;
③ 以前还有这种写法(老版的项目一般这么做):
a.使用MapperScannerConfigurer
<bean class="MapperScannerConfigurer">
<property name="basePackage" value="Dao接口包名"/>
<bean> 或者
b.采用实体DAO调用方式采用接口org.apache.ibatis.session.SqlSession的实现类org.mybatis.spring.SqlSessionTemplate
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory"></constructor-arg>
</bean>
<!-- 8.配置事务管理器 -->
<!--
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
-->
<mybatis-spring:scan base-package="com.ssm.mapper"/>
<!-- 9.启用注解式事务 -->
<!-- 在Service方法上使用@Transactional注解 -->
<!-- <tx:annotation-driven transaction-manager="transactionManager"/> -->
</beans>

@ -4,7 +4,6 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 配置Patient实体类的Bean -->
<bean id="patient" class="com.ssm.ioc.Patient">
<property name="patientId" value="1001"/>
<property name="patientName" value="张三"/>
@ -14,7 +13,6 @@
<property name="address" value="北京市朝阳区建国路100号"/>
</bean>
<!-- 配置Doctor实体类的Bean -->
<bean id="doctor" class="com.ssm.ioc.Doctor">
<property name="doctorId" value="2001"/>
<property name="doctorName" value="李医生"/>
@ -24,7 +22,6 @@
<property name="email" value="li.doctor@hospital.com"/>
</bean>
<!-- 配置Department实体类的Bean -->
<bean id="department" class="com.ssm.ioc.Department">
<property name="deptId" value="3001"/>
<property name="deptName" value="内科"/>
@ -34,7 +31,6 @@
<property name="description" value="内科是医院的核心科室,负责常见疾病的诊断和治疗"/>
</bean>
<!-- 配置Appointment实体类的Bean -->
<bean id="appointment" class="com.ssm.ioc.Appointment">
<property name="appointmentId" value="4001"/>
<property name="patientName" value="张三"/>
@ -44,4 +40,77 @@
<property name="status" value="已预约"/>
</bean>
</beans>
<bean id="medicine" class="com.ssm.ioc.Medicine">
<property name="medicineId" value="5001"/>
<property name="medicineName" value="阿莫西林"/>
<property name="specification" value="0.5g*20粒"/>
<property name="manufacturer" value="华北制药"/>
<property name="price" value="25.5"/>
<property name="type" value="抗生素"/>
<property name="description" value="用于治疗细菌感染"/>
</bean>
<bean id="registration" class="com.ssm.ioc.Registration">
<property name="registrationId" value="6001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="doctorName" value="李医生"/>
<property name="doctorId" value="2001"/>
<property name="department" value="内科"/>
<property name="registrationDate" value="2026-04-14"/>
<property name="status" value="已挂号"/>
</bean>
<bean id="medicalRecord" class="com.ssm.ioc.MedicalRecord">
<property name="recordId" value="7001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="doctorName" value="李医生"/>
<property name="doctorId" value="2001"/>
<property name="diagnosis" value="上呼吸道感染"/>
<property name="symptoms" value="发热、咳嗽、咽痛"/>
<property name="treatment" value="口服阿莫西林每日三次每次2粒"/>
<property name="recordDate" value="2026-04-14"/>
</bean>
<bean id="medicalOrder" class="com.ssm.ioc.MedicalOrder">
<property name="orderId" value="8001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="doctorName" value="李医生"/>
<property name="doctorId" value="2001"/>
<property name="medicineName" value="阿莫西林"/>
<property name="medicineId" value="5001"/>
<property name="dosage" value="0.5g"/>
<property name="frequency" value="每日三次"/>
<property name="usage" value="口服"/>
<property name="orderDate" value="2026-04-14"/>
<property name="status" value="已执行"/>
</bean>
<bean id="hospitalization" class="com.ssm.ioc.Hospitalization">
<property name="hospitalizationId" value="9001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="orderId" value="8001"/>
<property name="department" value="内科"/>
<property name="roomNo" value="301"/>
<property name="bedNo" value="01"/>
<property name="admitDate" value="2026-04-14"/>
<property name="dischargeDate" value="2026-04-20"/>
<property name="status" value="住院中"/>
</bean>
<bean id="expense" class="com.ssm.ioc.Expense">
<property name="expenseId" value="10001"/>
<property name="orderId" value="8001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="expenseType" value="药品费"/>
<property name="amount" value="25.5"/>
<property name="description" value="阿莫西林药费"/>
<property name="expenseDate" value="2026-04-14"/>
<property name="status" value="已结算"/>
</bean>
</beans>

@ -10,7 +10,8 @@ public class AdminController {
// 进入管理员页面
@RequestMapping("/admin")
@RequestMapping({"/admin", "/admin.action"})
@SuppressWarnings("SpringMVCViewInspection")
public String AdminIndex() {
return "admin/home";
}

@ -1,351 +0,0 @@
package com.ssm.controller;
import com.ssm.Utils.PageBean;
import com.ssm.entity.Demo;
import com.ssm.service.DemoService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.servlet.ModelAndView;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
* DemoController
* Demo
*/
public class DemoControllerTest {
private MockMvc mockMvc;
@Mock
private DemoService demoService;
@InjectMocks
private DemoController demoController;
// 测试常量
private static final String REDIRECT_URL = "/demo/findAllByPage.action?page=1";
/**
* MockMockMvc
*/
@Before
public void setUp() {
// 初始化Mock注解使用旧版API适配mockito 2.23.4
MockitoAnnotations.initMocks(this);
// 构建MockMvc
mockMvc = MockMvcBuilders.standaloneSetup(demoController).build();
}
/**
*
*/
@After
public void tearDown() throws Exception {
// mockito 2.23.4 使用 initMocks无需手动清理
}
/**
* add -
*/
@Test
public void testAdd_ReturnAddPage() throws Exception {
// 执行测试
ModelAndView mv = demoController.add();
// 验证返回的视图名称
assertEquals("admin/demo/add", mv.getViewName());
}
/**
* findAllByPage -
*/
@Test
public void testFindAllByPage_Success() throws Exception {
// 准备测试数据
int page = 1;
PageBean<Demo> pageBean = new PageBean<>();
pageBean.setPage(page);
pageBean.setLimitPage(6);
pageBean.setTotlePage(2);
pageBean.setList(Arrays.asList(new Demo(1, "测试1", "备注1")));
when(demoService.getDemoAll(page)).thenReturn(pageBean);
// 执行测试
mockMvc.perform(get("/demo/findAllByPage")
.param("page", String.valueOf(page))
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().isOk())
.andExpect(view().name("admin/demo/list"))
.andExpect(model().attributeExists("allProPageBean"));
// 验证服务层方法被调用
verify(demoService, times(1)).getDemoAll(page);
}
/**
* findById - ID
*/
@Test
public void testFindById_Success() throws Exception {
// 准备测试数据
Integer did = 1;
Demo demo = new Demo(did, "测试Demo", "测试备注");
when(demoService.getDemoById(did)).thenReturn(demo);
// 执行测试
mockMvc.perform(get("/demo/findById")
.param("did", String.valueOf(did))
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().isOk())
.andExpect(view().name("admin/demo/look"))
.andExpect(model().attribute("findByDid", demo));
// 验证服务层方法被调用
verify(demoService, times(1)).getDemoById(did);
}
/**
* findById - ID
*/
@Test
public void testFindById_NotFound() throws Exception {
// 准备测试数据
Integer did = 999;
when(demoService.getDemoById(did)).thenReturn(null);
// 执行测试
mockMvc.perform(get("/demo/findById")
.param("did", String.valueOf(did))
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().isOk())
.andExpect(view().name("admin/demo/look"))
.andExpect(model().attribute("findByDid", null));
// 验证服务层方法被调用
verify(demoService, times(1)).getDemoById(did);
}
/**
* addok -
*/
@Test
public void testAddOk_Success() throws Exception {
// 执行测试
mockMvc.perform(get("/demo/addOk")
.param("dname", "新Demo")
.param("comment", "新备注")
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl(REDIRECT_URL));
// 验证服务层方法被调用
verify(demoService, times(1)).addDemo(any(Demo.class));
}
/**
* updateById - ID
*/
@Test
public void testUpdateById_Success() throws Exception {
// 准备测试数据
Integer did = 1;
Demo demo = new Demo(did, "待更新Demo", "待更新备注");
when(demoService.getDemoById(did)).thenReturn(demo);
// 执行测试
mockMvc.perform(get("/demo/updateById")
.param("did", String.valueOf(did))
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().isOk())
.andExpect(view().name("admin/demo/edit"))
.andExpect(model().attribute("findByDid", demo));
// 验证服务层方法被调用
verify(demoService, times(1)).getDemoById(did);
}
/**
* updateOk -
*/
@Test
public void testUpdateOk_Success() throws Exception {
// 执行测试
mockMvc.perform(get("/demo/updateOk")
.param("did", "1")
.param("dname", "更新后的Demo")
.param("comment", "更新后的备注")
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl(REDIRECT_URL));
// 验证服务层方法被调用
verify(demoService, times(1)).updateDemo(any(Demo.class));
}
/**
* deleteById -
*/
@Test
public void testDeleteById_Success() throws Exception {
// 执行测试
mockMvc.perform(get("/demo/deleteById")
.param("did", "1")
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl(REDIRECT_URL));
// 验证服务层方法被调用
verify(demoService, times(1)).deleteDemoById(1);
}
/**
* searchDemoByCondition -
*/
@Test
public void testSearchDemoByCondition_Found() throws Exception {
// 准备测试数据
String condition = "测试";
List<Demo> demoList = Arrays.asList(
new Demo(1, "测试1", "备注1"),
new Demo(2, "测试2", "备注2")
);
when(demoService.searchDemoByCondition(condition)).thenReturn(demoList);
// 执行测试
mockMvc.perform(get("/demo/searchDemoByCondition")
.param("condition", condition)
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().isOk())
.andExpect(view().name("admin/demo/search"))
.andExpect(model().attributeExists("srList"))
.andExpect(model().attribute("srList", demoList));
// 验证服务层方法被调用
verify(demoService, times(1)).searchDemoByCondition(condition);
}
/**
* searchDemoByCondition -
*/
@Test
public void testSearchDemoByCondition_NotFound() throws Exception {
// 准备测试数据
String condition = "不存在的条件";
List<Demo> emptyList = Arrays.asList();
when(demoService.searchDemoByCondition(condition)).thenReturn(emptyList);
// 执行测试
mockMvc.perform(get("/demo/searchDemoByCondition")
.param("condition", condition)
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().isOk())
.andExpect(view().name("admin/demo/search"))
.andExpect(model().attribute("srList", emptyList));
// 验证服务层方法被调用
verify(demoService, times(1)).searchDemoByCondition(condition);
}
/**
* findDemoByDid -
*/
@Test
public void testFindDemoByDid_Success() throws Exception {
// 准备测试数据
int did = 1;
Demo demo = new Demo(did, "前台展示Demo", "前台备注");
when(demoService.getDemoById(did)).thenReturn(demo);
// 执行测试
mockMvc.perform(get("/demo/findDemoByDid")
.param("did", String.valueOf(did))
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().isOk())
.andExpect(view().name("demo"))
.andExpect(model().attribute("demo", demo));
// 验证服务层方法被调用
verify(demoService, times(1)).getDemoById(did);
}
/**
* ControllerDemoService
*/
@Test
public void testControllerInjection() {
// 验证demoController不为null
assertNotNull("DemoController不应为null", demoController);
// 验证demoService已被注入虽然是mock对象
assertNotNull("DemoService应被注入", demoController.demoService);
}
/**
* addok - Demo
*/
@Test
public void testAddOk_DemoObjectPassed() throws Exception {
// 执行测试
String expectedName = "新Demo名称";
String expectedComment = "新Demo备注";
mockMvc.perform(get("/demo/addOk")
.param("dname", expectedName)
.param("comment", expectedComment)
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().is3xxRedirection());
// 验证addDemo被调用并且传入的Demo对象属性正确
verify(demoService).addDemo(argThat(demo ->
demo != null &&
expectedName.equals(demo.getDname()) &&
expectedComment.equals(demo.getComment())
));
}
/**
* updateOk - Demo
*/
@Test
public void testUpdateOk_DemoObjectPassed() throws Exception {
// 执行测试
String expectedId = "1";
String expectedName = "更新后的名称";
String expectedComment = "更新后的备注";
mockMvc.perform(get("/demo/updateOk")
.param("did", expectedId)
.param("dname", expectedName)
.param("comment", expectedComment)
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().is3xxRedirection());
// 验证updateDemo被调用并且传入的Demo对象属性正确
verify(demoService).updateDemo(argThat(demo ->
demo != null &&
expectedId.equals(String.valueOf(demo.getDid())) &&
expectedName.equals(demo.getDname()) &&
expectedComment.equals(demo.getComment())
));
}
}

@ -1,7 +1,5 @@
package com.ssm.entity;
import java.util.Date;
public class Demo {
private Integer did; //demo id

@ -14,6 +14,7 @@ public class Appointment {
public Appointment() {
}
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public Appointment(Integer appointmentId, String patientName, String doctorName, String department, String appointmentDate, String status) {
this.appointmentId = appointmentId;
this.patientName = patientName;

@ -14,6 +14,7 @@ public class Department {
public Department() {
}
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public Department(Integer deptId, String deptName, String location, String director, String phone, String description) {
this.deptId = deptId;
this.deptName = deptName;

@ -14,6 +14,7 @@ public class Doctor {
public Doctor() {
}
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public Doctor(Integer doctorId, String doctorName, String department, String title, String phone, String email) {
this.doctorId = doctorId;
this.doctorName = doctorName;

@ -1,44 +1,65 @@
package com.ssm.ioc;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* IOC
* SpringBean
*/
public class TestIoc {
public static void main(String[] args) {
// 1. 加载Spring配置文件创建IOC容器
ApplicationContext context = new ClassPathXmlApplicationContext("bean-ioc.xml");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("bean-ioc.xml");
System.out.println("========== Spring IOC容器测试 ==========");
System.out.println();
// 2. 从容器中获取Patient对象
Patient patient = (Patient) context.getBean("patient");
System.out.println("【患者信息】");
System.out.println(patient);
System.out.println();
// 3. 从容器中获取Doctor对象
Doctor doctor = (Doctor) context.getBean("doctor");
System.out.println("【医生信息】");
System.out.println(doctor);
System.out.println();
// 4. 从容器中获取Department对象
Department department = (Department) context.getBean("department");
System.out.println("【科室信息】");
System.out.println(department);
System.out.println();
// 5. 从容器中获取Appointment对象
Appointment appointment = (Appointment) context.getBean("appointment");
System.out.println("【预约信息】");
System.out.println(appointment);
System.out.println();
Medicine medicine = (Medicine) context.getBean("medicine");
System.out.println("【药品信息】");
System.out.println(medicine);
System.out.println();
Registration registration = (Registration) context.getBean("registration");
System.out.println("【挂号信息】");
System.out.println(registration);
System.out.println();
MedicalRecord medicalRecord = (MedicalRecord) context.getBean("medicalRecord");
System.out.println("【病历信息】");
System.out.println(medicalRecord);
System.out.println();
MedicalOrder medicalOrder = (MedicalOrder) context.getBean("medicalOrder");
System.out.println("【医嘱信息】");
System.out.println(medicalOrder);
System.out.println();
Hospitalization hospitalization = (Hospitalization) context.getBean("hospitalization");
System.out.println("【住院信息】");
System.out.println(hospitalization);
System.out.println();
Expense expense = (Expense) context.getBean("expense");
System.out.println("【费用信息】");
System.out.println(expense);
System.out.println();
System.out.println("========== 测试完成 ==========");
context.close();
}
}
}

@ -6,10 +6,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import static org.junit.Assert.*;
/**
* IOC
* SpringBean
*/
public class TestIocTest {
private ClassPathXmlApplicationContext context;
@ -17,10 +13,13 @@ public class TestIocTest {
private Doctor doctor;
private Department department;
private Appointment appointment;
private Medicine medicine;
private Registration registration;
private MedicalRecord medicalRecord;
private MedicalOrder medicalOrder;
private Hospitalization hospitalization;
private Expense expense;
/**
* Spring IOC
*/
@Before
public void setUp() {
context = new ClassPathXmlApplicationContext("bean-ioc.xml");
@ -28,17 +27,17 @@ public class TestIocTest {
doctor = (Doctor) context.getBean("doctor");
department = (Department) context.getBean("department");
appointment = (Appointment) context.getBean("appointment");
medicine = (Medicine) context.getBean("medicine");
registration = (Registration) context.getBean("registration");
medicalRecord = (MedicalRecord) context.getBean("medicalRecord");
medicalOrder = (MedicalOrder) context.getBean("medicalOrder");
hospitalization = (Hospitalization) context.getBean("hospitalization");
expense = (Expense) context.getBean("expense");
}
/**
* Patient Bean
*/
@Test
public void testGetPatientBean() {
// 验证对象不为null
assertNotNull("Patient对象不应为null", patient);
// 验证各个属性值是否正确注入
assertEquals("患者ID应为1001", Integer.valueOf(1001), patient.getPatientId());
assertEquals("患者姓名应为张三", "张三", patient.getPatientName());
assertEquals("性别应为男", "男", patient.getGender());
@ -47,15 +46,9 @@ public class TestIocTest {
assertEquals("地址应为北京市朝阳区建国路100号", "北京市朝阳区建国路100号", patient.getAddress());
}
/**
* Doctor Bean
*/
@Test
public void testGetDoctorBean() {
// 验证对象不为null
assertNotNull("Doctor对象不应为null", doctor);
// 验证各个属性值是否正确注入
assertEquals("医生ID应为2001", Integer.valueOf(2001), doctor.getDoctorId());
assertEquals("医生姓名应为李医生", "李医生", doctor.getDoctorName());
assertEquals("科室应为内科", "内科", doctor.getDepartment());
@ -64,15 +57,9 @@ public class TestIocTest {
assertEquals("邮箱应为li.doctor@hospital.com", "li.doctor@hospital.com", doctor.getEmail());
}
/**
* Department Bean
*/
@Test
public void testGetDepartmentBean() {
// 验证对象不为null
assertNotNull("Department对象不应为null", department);
// 验证各个属性值是否正确注入
assertEquals("科室ID应为3001", Integer.valueOf(3001), department.getDeptId());
assertEquals("科室名称应为内科", "内科", department.getDeptName());
assertEquals("位置应为门诊楼3层", "门诊楼3层", department.getLocation());
@ -81,15 +68,9 @@ public class TestIocTest {
assertEquals("描述应正确", "内科是医院的核心科室,负责常见疾病的诊断和治疗", department.getDescription());
}
/**
* Appointment Bean
*/
@Test
public void testGetAppointmentBean() {
// 验证对象不为null
assertNotNull("Appointment对象不应为null", appointment);
// 验证各个属性值是否正确注入
assertEquals("预约ID应为4001", Integer.valueOf(4001), appointment.getAppointmentId());
assertEquals("患者姓名应为张三", "张三", appointment.getPatientName());
assertEquals("医生姓名应为李医生", "李医生", appointment.getDoctorName());
@ -98,71 +79,179 @@ public class TestIocTest {
assertEquals("状态应为已预约", "已预约", appointment.getStatus());
}
/**
* Bean
*/
@Test
public void testGetMedicineBean() {
assertNotNull("Medicine对象不应为null", medicine);
assertEquals("药品ID应为5001", Integer.valueOf(5001), medicine.getMedicineId());
assertEquals("药品名称应为阿莫西林", "阿莫西林", medicine.getMedicineName());
assertEquals("规格应为0.5g*20粒", "0.5g*20粒", medicine.getSpecification());
assertEquals("生产厂家应为华北制药", "华北制药", medicine.getManufacturer());
assertEquals("价格应为25.5", Double.valueOf(25.5), medicine.getPrice());
assertEquals("类型应为抗生素", "抗生素", medicine.getType());
assertEquals("描述应为用于治疗细菌感染", "用于治疗细菌感染", medicine.getDescription());
}
@Test
public void testGetRegistrationBean() {
assertNotNull("Registration对象不应为null", registration);
assertEquals("挂号ID应为6001", Integer.valueOf(6001), registration.getRegistrationId());
assertEquals("患者姓名应为张三", "张三", registration.getPatientName());
assertEquals("患者ID应为1001", "1001", registration.getPatientId());
assertEquals("医生姓名应为李医生", "李医生", registration.getDoctorName());
assertEquals("医生ID应为2001", "2001", registration.getDoctorId());
assertEquals("科室应为内科", "内科", registration.getDepartment());
assertEquals("挂号日期应为2026-04-14", "2026-04-14", registration.getRegistrationDate());
assertEquals("状态应为已挂号", "已挂号", registration.getStatus());
}
@Test
public void testGetMedicalRecordBean() {
assertNotNull("MedicalRecord对象不应为null", medicalRecord);
assertEquals("病历ID应为7001", Integer.valueOf(7001), medicalRecord.getRecordId());
assertEquals("患者姓名应为张三", "张三", medicalRecord.getPatientName());
assertEquals("患者ID应为1001", "1001", medicalRecord.getPatientId());
assertEquals("医生姓名应为李医生", "李医生", medicalRecord.getDoctorName());
assertEquals("医生ID应为2001", "2001", medicalRecord.getDoctorId());
assertEquals("诊断应为上呼吸道感染", "上呼吸道感染", medicalRecord.getDiagnosis());
assertEquals("症状应为发热、咳嗽、咽痛", "发热、咳嗽、咽痛", medicalRecord.getSymptoms());
assertEquals("治疗方案应正确", "口服阿莫西林每日三次每次2粒", medicalRecord.getTreatment());
assertEquals("记录日期应为2026-04-14", "2026-04-14", medicalRecord.getRecordDate());
}
@Test
public void testGetMedicalOrderBean() {
assertNotNull("MedicalOrder对象不应为null", medicalOrder);
assertEquals("医嘱ID应为8001", Integer.valueOf(8001), medicalOrder.getOrderId());
assertEquals("患者姓名应为张三", "张三", medicalOrder.getPatientName());
assertEquals("患者ID应为1001", "1001", medicalOrder.getPatientId());
assertEquals("医生姓名应为李医生", "李医生", medicalOrder.getDoctorName());
assertEquals("医生ID应为2001", "2001", medicalOrder.getDoctorId());
assertEquals("药品名称应为阿莫西林", "阿莫西林", medicalOrder.getMedicineName());
assertEquals("药品ID应为5001", "5001", medicalOrder.getMedicineId());
assertEquals("剂量应为0.5g", "0.5g", medicalOrder.getDosage());
assertEquals("频次应为每日三次", "每日三次", medicalOrder.getFrequency());
assertEquals("用法应为口服", "口服", medicalOrder.getUsage());
assertEquals("医嘱日期应为2026-04-14", "2026-04-14", medicalOrder.getOrderDate());
assertEquals("状态应为已执行", "已执行", medicalOrder.getStatus());
}
@Test
public void testGetHospitalizationBean() {
assertNotNull("Hospitalization对象不应为null", hospitalization);
assertEquals("住院ID应为9001", Integer.valueOf(9001), hospitalization.getHospitalizationId());
assertEquals("患者姓名应为张三", "张三", hospitalization.getPatientName());
assertEquals("患者ID应为1001", "1001", hospitalization.getPatientId());
assertEquals("医嘱ID应为8001", "8001", hospitalization.getOrderId());
assertEquals("科室应为内科", "内科", hospitalization.getDepartment());
assertEquals("病房号应为301", "301", hospitalization.getRoomNo());
assertEquals("床位号应为01", "01", hospitalization.getBedNo());
assertEquals("入院日期应为2026-04-14", "2026-04-14", hospitalization.getAdmitDate());
assertEquals("出院日期应为2026-04-20", "2026-04-20", hospitalization.getDischargeDate());
assertEquals("状态应为住院中", "住院中", hospitalization.getStatus());
}
@Test
public void testGetExpenseBean() {
assertNotNull("Expense对象不应为null", expense);
assertEquals("费用ID应为10001", Integer.valueOf(10001), expense.getExpenseId());
assertEquals("医嘱ID应为8001", "8001", expense.getOrderId());
assertEquals("患者姓名应为张三", "张三", expense.getPatientName());
assertEquals("患者ID应为1001", "1001", expense.getPatientId());
assertEquals("费用类型应为药品费", "药品费", expense.getExpenseType());
assertEquals("金额应为25.5", Double.valueOf(25.5), expense.getAmount());
assertEquals("描述应为阿莫西林药费", "阿莫西林药费", expense.getDescription());
assertEquals("费用日期应为2026-04-14", "2026-04-14", expense.getExpenseDate());
assertEquals("状态应为已结算", "已结算", expense.getStatus());
}
@Test
public void testAllBeansCreation() {
// 验证所有对象都不为null
assertNotNull("Patient对象应成功创建", patient);
assertNotNull("Doctor对象应成功创建", doctor);
assertNotNull("Department对象应成功创建", department);
assertNotNull("Appointment对象应成功创建", appointment);
assertNotNull("Medicine对象应成功创建", medicine);
assertNotNull("Registration对象应成功创建", registration);
assertNotNull("MedicalRecord对象应成功创建", medicalRecord);
assertNotNull("MedicalOrder对象应成功创建", medicalOrder);
assertNotNull("Hospitalization对象应成功创建", hospitalization);
assertNotNull("Expense对象应成功创建", expense);
// 验证对象的toString方法能正常执行
assertNotNull("Patient.toString()不应为null", patient.toString());
assertNotNull("Doctor.toString()不应为null", doctor.toString());
assertNotNull("Department.toString()不应为null", department.toString());
assertNotNull("Appointment.toString()不应为null", appointment.toString());
assertNotNull("Medicine.toString()不应为null", medicine.toString());
assertNotNull("Registration.toString()不应为null", registration.toString());
assertNotNull("MedicalRecord.toString()不应为null", medicalRecord.toString());
assertNotNull("MedicalOrder.toString()不应为null", medicalOrder.toString());
assertNotNull("Hospitalization.toString()不应为null", hospitalization.toString());
assertNotNull("Expense.toString()不应为null", expense.toString());
// 验证toString输出包含关键信息
assertTrue("Patient.toString()应包含患者姓名", patient.toString().contains("张三"));
assertTrue("Doctor.toString()应包含医生姓名", doctor.toString().contains("李医生"));
assertTrue("Department.toString()应包含科室名称", department.toString().contains("内科"));
assertTrue("Appointment.toString()应包含预约状态", appointment.toString().contains("已预约"));
assertTrue("Medicine.toString()应包含药品名称", medicine.toString().contains("阿莫西林"));
assertTrue("Registration.toString()应包含挂号状态", registration.toString().contains("已挂号"));
assertTrue("MedicalRecord.toString()应包含诊断结果", medicalRecord.toString().contains("上呼吸道感染"));
assertTrue("MedicalOrder.toString()应包含医嘱状态", medicalOrder.toString().contains("已执行"));
assertTrue("Hospitalization.toString()应包含住院状态", hospitalization.toString().contains("住院中"));
assertTrue("Expense.toString()应包含费用状态", expense.toString().contains("已结算"));
}
/**
* Bean
*/
@Test
public void testBeanSingleton() {
// 再次从容器获取Bean
Patient patient1 = (Patient) context.getBean("patient");
Patient patient2 = (Patient) context.getBean("patient");
Doctor doctor1 = (Doctor) context.getBean("doctor");
Doctor doctor2 = (Doctor) context.getBean("doctor");
// Spring默认Bean是单例的应该是同一实例
assertSame("两次获取的Patient应为同一实例", patient1, patient2);
assertSame("两次获取的Doctor应为同一实例", doctor1, doctor2);
}
/**
* Bean
*/
@Test
public void testBeanTypes() {
// 获取Bean实例
Object patient = context.getBean("patient");
Object doctor = context.getBean("doctor");
Object department = context.getBean("department");
Object appointment = context.getBean("appointment");
Object medicine = context.getBean("medicine");
Object registration = context.getBean("registration");
Object medicalRecord = context.getBean("medicalRecord");
Object medicalOrder = context.getBean("medicalOrder");
Object hospitalization = context.getBean("hospitalization");
Object expense = context.getBean("expense");
// 验证Patient Bean的类型
assertNotNull("Patient Bean不应为null", patient);
assertTrue("Patient Bean应为Patient类型", patient instanceof Patient);
// 验证Doctor Bean的类型
assertNotNull("Doctor Bean不应为null", doctor);
assertTrue("Doctor Bean应为Doctor类型", doctor instanceof Doctor);
// 验证Department Bean的类型
assertNotNull("Department Bean不应为null", department);
assertTrue("Department Bean应为Department类型", department instanceof Department);
// 验证Appointment Bean的类型
assertNotNull("Appointment Bean不应为null", appointment);
assertTrue("Appointment Bean应为Appointment类型", appointment instanceof Appointment);
assertNotNull("Medicine Bean不应为null", medicine);
assertTrue("Medicine Bean应为Medicine类型", medicine instanceof Medicine);
assertNotNull("Registration Bean不应为null", registration);
assertTrue("Registration Bean应为Registration类型", registration instanceof Registration);
assertNotNull("MedicalRecord Bean不应为null", medicalRecord);
assertTrue("MedicalRecord Bean应为MedicalRecord类型", medicalRecord instanceof MedicalRecord);
assertNotNull("MedicalOrder Bean不应为null", medicalOrder);
assertTrue("MedicalOrder Bean应为MedicalOrder类型", medicalOrder instanceof MedicalOrder);
assertNotNull("Hospitalization Bean不应为null", hospitalization);
assertTrue("Hospitalization Bean应为Hospitalization类型", hospitalization instanceof Hospitalization);
assertNotNull("Expense Bean不应为null", expense);
assertTrue("Expense Bean应为Expense类型", expense instanceof Expense);
}
}
}

@ -6,6 +6,8 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
//操作mybatis的接口
// 注意:暂时不使用@Repository注解因为数据库配置已禁用
// 启用数据库时需要使用MapperScannerConfigurer或@MapperScan来扫描
public interface DemoMapper {
/*
* 1mapper.xmlid

@ -2,51 +2,40 @@ package com.ssm.service;
import com.ssm.Utils.PageBean;
import com.ssm.entity.Demo;
import com.ssm.mapper.DemoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class DemoService {
@Autowired
private DemoMapper demoMapper;
@SuppressWarnings("unused")
public PageBean<Demo> getDemoAll(int page) {
// 临时返回模拟数据
PageBean<Demo> pageBean = new PageBean<>();
pageBean.setPage(page);
// 设置7个
int limitPage = 6;
pageBean.setLimitPage(limitPage);
// 查询一共有多少页
int totlePage = demoMapper.countTotlePage();
if (Math.ceil(totlePage % limitPage) == 0) {
totlePage = totlePage / limitPage;
} else {
totlePage = totlePage / limitPage + 1;
}
pageBean.setTotlePage(totlePage);
int beginPage = (page - 1) * limitPage;
List<Demo> list = demoMapper.getDemoAll(beginPage, limitPage);
List<Demo> list = new ArrayList<>();
list.add(new Demo(1, "Test1", "Description1"));
list.add(new Demo(2, "Test2", "Description2"));
pageBean.setList(list);
return pageBean;
}
public Demo getDemoById(Integer id) {
return demoMapper.findDemoByDid(id);
return new Demo(id, "Demo" + id, "Description" + id);
}
public void addDemo(Demo demo) {
demoMapper.addDemo(demo);
// 临时空实现
}
public void updateDemo(Demo demo) {
demoMapper.updateDemo(demo);
// 临时空实现
}
public void deleteDemoById(Integer id) {
demoMapper.deleteDemoById(id);
// 临时空实现
}
public List<Demo> searchDemoByCondition(String condition){
return new ArrayList<>();
}
public List<Demo> findDemoByDId(Integer did){
return new ArrayList<>();
}
public List<Demo> searchDemoByCondition(String condition){ return demoMapper.searchDemoByCondition(condition); }
public List<Demo> findDemoByDId(Integer did){return demoMapper.findDemoByDId(did);}
}

@ -1,463 +0,0 @@
package com.ssm.service;
import com.ssm.Utils.PageBean;
import com.ssm.entity.Demo;
import com.ssm.mapper.DemoMapper;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
/**
* DemoService
* Demo
*/
public class DemoServiceTest {
@Mock
private DemoMapper demoMapper;
@InjectMocks
private DemoService demoService;
// 测试常量
private static final Integer TEST_ID = 1;
private static final String TEST_NAME = "测试Demo";
private static final String TEST_COMMENT = "测试备注";
private static final int PAGE_SIZE = 6;
/**
* Mock
*/
@Before
public void setUp() {
// 初始化Mock注解使用旧版API适配mockito 2.23.4
MockitoAnnotations.initMocks(this);
}
/**
*
*/
@After
public void tearDown() throws Exception {
// mockito 2.23.4 使用 initMocks无需手动清理
}
/**
* getDemoAll -
*/
@Test
public void testGetDemoAll_FirstPage() {
// 准备测试数据
int page = 1;
int totalCount = 15; // 总共15条记录
List<Demo> mockList = Arrays.asList(
new Demo(1, "Demo1", "备注1"),
new Demo(2, "Demo2", "备注2")
);
// Mock行为
when(demoMapper.countTotlePage()).thenReturn(totalCount);
when(demoMapper.getDemoAll(0, PAGE_SIZE)).thenReturn(mockList);
// 执行测试
PageBean<Demo> result = demoService.getDemoAll(page);
// 验证结果
assertNotNull("PageBean不应为null", result);
assertEquals("当前页码应为1", 1, result.getPage());
assertEquals("每页数量应为6", PAGE_SIZE, result.getLimitPage());
assertEquals("总页数应为3", 3, result.getTotlePage()); // 15/6=2.5向上取整为3
assertNotNull("列表不应为null", result.getList());
assertEquals("列表大小应为2", 2, result.getList().size());
// 验证调用
verify(demoMapper, times(1)).countTotlePage();
verify(demoMapper, times(1)).getDemoAll(0, PAGE_SIZE);
}
/**
* getDemoAll -
*/
@Test
public void testGetDemoAll_SecondPage() {
// 准备测试数据
int page = 2;
int totalCount = 15;
List<Demo> mockList = Arrays.asList(
new Demo(7, "Demo7", "备注7"),
new Demo(8, "Demo8", "备注8")
);
// Mock行为
when(demoMapper.countTotlePage()).thenReturn(totalCount);
when(demoMapper.getDemoAll(6, PAGE_SIZE)).thenReturn(mockList);
// 执行测试
PageBean<Demo> result = demoService.getDemoAll(page);
// 验证结果
assertNotNull("PageBean不应为null", result);
assertEquals("当前页码应为2", 2, result.getPage());
assertEquals("总页数应为3", 3, result.getTotlePage());
assertEquals("列表大小应为2", 2, result.getList().size());
// 验证调用beginPage应该是(2-1)*6=6
verify(demoMapper).getDemoAll(6, PAGE_SIZE);
}
/**
* getDemoAll -
*/
@Test
public void testGetDemoAll_LastPage() {
// 准备测试数据
int page = 3;
int totalCount = 15;
List<Demo> mockList = Collections.singletonList(
new Demo(13, "Demo13", "备注13")
);
// Mock行为
when(demoMapper.countTotlePage()).thenReturn(totalCount);
when(demoMapper.getDemoAll(12, PAGE_SIZE)).thenReturn(mockList);
// 执行测试
PageBean<Demo> result = demoService.getDemoAll(page);
// 验证结果
assertNotNull("PageBean不应为null", result);
assertEquals("当前页码应为3", 3, result.getPage());
assertEquals("总页数应为3", 3, result.getTotlePage());
assertEquals("列表大小应为1", 1, result.getList().size());
// 验证调用beginPage应该是(3-1)*6=12
verify(demoMapper).getDemoAll(12, PAGE_SIZE);
}
/**
* getDemoAll -
*/
@Test
public void testGetDemoAll_EmptyResult() {
// 准备测试数据
int page = 1;
int totalCount = 0;
List<Demo> mockList = Collections.emptyList();
// Mock行为
when(demoMapper.countTotlePage()).thenReturn(totalCount);
when(demoMapper.getDemoAll(0, PAGE_SIZE)).thenReturn(mockList);
// 执行测试
PageBean<Demo> result = demoService.getDemoAll(page);
// 验证结果
assertNotNull("PageBean不应为null", result);
assertEquals("当前页码应为1", 1, result.getPage());
assertEquals("总页数应为0", 0, result.getTotlePage());
assertNotNull("列表不应为null", result.getList());
assertTrue("列表应为空", result.getList().isEmpty());
}
/**
* getDemoAll -
*/
@Test
public void testGetDemoAll_ExactDivision() {
// 准备测试数据18条记录每页6条正好3页
int page = 1;
int totalCount = 18;
List<Demo> mockList = Arrays.asList(
new Demo(1, "Demo1", "备注1"),
new Demo(2, "Demo2", "备注2")
);
// Mock行为
when(demoMapper.countTotlePage()).thenReturn(totalCount);
when(demoMapper.getDemoAll(0, PAGE_SIZE)).thenReturn(mockList);
// 执行测试
PageBean<Demo> result = demoService.getDemoAll(page);
// 验证结果18/6=3应该正好3页
assertEquals("总页数应为3", 3, result.getTotlePage());
}
/**
* getDemoById -
*/
@Test
public void testGetDemoById_Success() {
// 准备测试数据
Demo expectedDemo = new Demo(TEST_ID, TEST_NAME, TEST_COMMENT);
// Mock行为
when(demoMapper.findDemoByDid(TEST_ID)).thenReturn(expectedDemo);
// 执行测试
Demo result = demoService.getDemoById(TEST_ID);
// 验证结果
assertNotNull("Demo不应为null", result);
assertEquals("ID应匹配", TEST_ID, result.getDid());
assertEquals("名称应匹配", TEST_NAME, result.getDname());
assertEquals("备注应匹配", TEST_COMMENT, result.getComment());
// 验证调用
verify(demoMapper, times(1)).findDemoByDid(TEST_ID);
}
/**
* getDemoById - ID
*/
@Test
public void testGetDemoById_NotFound() {
// Mock行为返回null
when(demoMapper.findDemoByDid(999)).thenReturn(null);
// 执行测试
Demo result = demoService.getDemoById(999);
// 验证结果
assertNull("不存在的ID应返回null", result);
}
/**
* addDemo -
*/
@Test
public void testAddDemo_Success() {
// 准备测试数据
Demo demo = new Demo(TEST_NAME, TEST_COMMENT);
// 执行测试
demoService.addDemo(demo);
// 验证调用
verify(demoMapper, times(1)).addDemo(demo);
}
/**
* addDemo -
*/
@Test(expected = NullPointerException.class)
public void testAddDemo_NullDemo() {
// 执行测试应该抛出NullPointerException
demoService.addDemo(null);
}
/**
* updateDemo -
*/
@Test
public void testUpdateDemo_Success() {
// 准备测试数据
Demo demo = new Demo(TEST_ID, TEST_NAME, TEST_COMMENT);
// 执行测试
demoService.updateDemo(demo);
// 验证调用
verify(demoMapper, times(1)).updateDemo(demo);
}
/**
* updateDemo -
*/
@Test
public void testUpdateDemo_NonExistent() {
// 准备测试数据
Demo demo = new Demo(999, "不存在的Demo", "备注");
// 执行测试
demoService.updateDemo(demo);
// 验证调用仍然发生(由数据库层处理不存在的情况)
verify(demoMapper, times(1)).updateDemo(demo);
}
/**
* deleteDemoById -
*/
@Test
public void testDeleteDemoById_Success() {
// 执行测试
demoService.deleteDemoById(TEST_ID);
// 验证调用
verify(demoMapper, times(1)).deleteDemoById(TEST_ID);
}
/**
* deleteDemoById - ID
*/
@Test
public void testDeleteDemoById_NonExistent() {
// 执行测试
demoService.deleteDemoById(999);
// 验证调用仍然发生(由数据库层处理不存在的情况)
verify(demoMapper, times(1)).deleteDemoById(999);
}
/**
* searchDemoByCondition -
*/
@Test
public void testSearchDemoByCondition_Success() {
// 准备测试数据
String condition = "测试";
List<Demo> expectedList = Arrays.asList(
new Demo(1, "测试Demo1", "测试备注"),
new Demo(2, "测试Demo2", "普通备注")
);
// Mock行为
when(demoMapper.searchDemoByCondition(condition)).thenReturn(expectedList);
// 执行测试
List<Demo> result = demoService.searchDemoByCondition(condition);
// 验证结果
assertNotNull("搜索结果不应为null", result);
assertEquals("结果大小应为2", 2, result.size());
// 验证调用
verify(demoMapper, times(1)).searchDemoByCondition(condition);
}
/**
* searchDemoByCondition -
*/
@Test
public void testSearchDemoByCondition_EmptyCondition() {
// 准备测试数据
String condition = "";
List<Demo> expectedList = Collections.emptyList();
// Mock行为
when(demoMapper.searchDemoByCondition(condition)).thenReturn(expectedList);
// 执行测试
List<Demo> result = demoService.searchDemoByCondition(condition);
// 验证结果
assertNotNull("搜索结果不应为null", result);
assertTrue("空条件应返回空列表", result.isEmpty());
}
/**
* searchDemoByCondition -
*/
@Test
public void testSearchDemoByCondition_NoMatch() {
// 准备测试数据
String condition = "不存在的关键词";
List<Demo> expectedList = Collections.emptyList();
// Mock行为
when(demoMapper.searchDemoByCondition(condition)).thenReturn(expectedList);
// 执行测试
List<Demo> result = demoService.searchDemoByCondition(condition);
// 验证结果
assertTrue("无匹配应返回空列表", result.isEmpty());
}
/**
* findDemoByDId -
*/
@Test
public void testFindDemoByDId_Success() {
// 准备测试数据
List<Demo> expectedList = Arrays.asList(
new Demo(1, "Demo1", "备注1"),
new Demo(2, "Demo2", "备注2")
);
// Mock行为
when(demoMapper.findDemoByDId(TEST_ID)).thenReturn(expectedList);
// 执行测试
List<Demo> result = demoService.findDemoByDId(TEST_ID);
// 验证结果
assertNotNull("结果不应为null", result);
assertEquals("结果大小应为2", 2, result.size());
// 验证调用
verify(demoMapper, times(1)).findDemoByDId(TEST_ID);
}
/**
* findDemoByDId -
*/
@Test
public void testFindDemoByDId_EmptyResult() {
// Mock行为
when(demoMapper.findDemoByDId(999)).thenReturn(Collections.emptyList());
// 执行测试
List<Demo> result = demoService.findDemoByDId(999);
// 验证结果
assertNotNull("结果不应为null", result);
assertTrue("结果应为空列表", result.isEmpty());
}
/**
* -
*/
@Test
public void testPagination_BoundaryValue() {
// 准备测试数据13条记录每页6条应该是3页13/6=2.166...向上取整为3
int page = 1;
int totalCount = 13;
List<Demo> mockList = Collections.emptyList();
// Mock行为
when(demoMapper.countTotlePage()).thenReturn(totalCount);
when(demoMapper.getDemoAll(0, PAGE_SIZE)).thenReturn(mockList);
// 执行测试
PageBean<Demo> result = demoService.getDemoAll(page);
// 验证结果应该有3页
assertEquals("总页数应为3", 3, result.getTotlePage());
}
/**
* -
*/
@Test
public void testPagination_SingleRecord() {
// 准备测试数据
int page = 1;
int totalCount = 1;
List<Demo> mockList = Collections.singletonList(
new Demo(1, "唯一记录", "备注")
);
// Mock行为
when(demoMapper.countTotlePage()).thenReturn(totalCount);
when(demoMapper.getDemoAll(0, PAGE_SIZE)).thenReturn(mockList);
// 执行测试
PageBean<Demo> result = demoService.getDemoAll(page);
// 验证结果
assertEquals("总页数应为1", 1, result.getTotlePage());
assertEquals("列表大小应为1", 1, result.getList().size());
}
}

@ -1,4 +1,4 @@
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/ssm_farm?serverTimezone=Asia/Shanghai
url=jdbc:mysql://localhost:3306/ssm_farm?useSSL=false&serverTimezone=Asia/Shanghai
user=root
password=root

@ -9,33 +9,43 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd">
<!-- 配置扫描器
只扫描标了@Controller的控制器
use-default-filters="false"禁用掉默认的过滤行为,只包含才会生效。即:
<context:component-scan base-package="com.ssm" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan> -->
<!-- <context:component-scan base-package="com.ssm"></context:component-scan> -->
<context:component-scan base-package="com.ssm" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- 视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"></property> <!-- 前缀 -->
<property name="suffix" value=".jsp"></property> <!-- 后缀 -->
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
<property name="contentType" value="text/html;charset=UTF-8"></property>
</bean>
<!-- 处理动态资源是SpringMVC的基础配置可以协调很多功能一般写SpringMVC项目都加上 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 正确的处理静态资源 -->
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value="text/html;charset=UTF-8"/>
</bean>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
</mvc:message-converters>
</mvc:annotation-driven>
<mvc:default-servlet-handler/>
<bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<mvc:resources mapping="/static/**" location="/static/"/>
<mvc:resources mapping="/css/**" location="/css/"/>
<mvc:resources mapping="/js/**" location="/js/"/>
<mvc:resources mapping="/images/**" location="/images/"/>
<bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
</bean>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize">
<value>5242880</value>
</property>
<property name="maxUploadSize" value="5242880"/>
<property name="defaultEncoding" value="UTF-8"/>
</bean>
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="defaultErrorView" value="error"/>
<property name="exceptionAttribute" value="exception"/>
</bean>
</beans>
</beans>

@ -2,84 +2,70 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
xsi:schemaLocation="http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<!-- 1.自动扫描包希望Spring管理所有业务逻辑组件、Bean等,SpringMVC负责网站跳转逻辑的控制Controller
注意①当springmvc.xml配置了只扫描@Controller此处就要配
除了标了@Controller注解的控制器以外都扫描即配置子标签
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> -->
<!-- 1.自动扫描包使用注解方式管理Bean -->
<!-- 扫描@Service、@Repository、@Component等注解 -->
<context:component-scan base-package="com.ssm">
<!-- 排除@Controller注解由SpringMVC管理 -->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- 2.引入db.properties
注意:①方式二:<bean id="" class="PropertyPlaceholderConfigurer"> -->
<context:property-placeholder location="classpath:db.properties"/>
<!-- 2.启用注解驱动 -->
<!-- 支持@Autowired、@Value等注解 -->
<context:annotation-config/>
<!-- 3.引入数据库的数据源配置:
注意①还可以配置事务控制、AOP等
②当使用c3p0连接池时配置如下
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${driver}"></property>
<property name="jdbcUrl" value="${url}"></property>
<property name="user" value="${user}"></property>
<property name="password" value="${password}"></property>
</bean> -->
<!-- 3.以下AOP和事务配置暂时注释,需要时再启用 -->
<!-- ============================================ -->
<!-- 以下配置暂时注释,需要数据库时再启用 -->
<!-- ============================================ -->
<!-- 4.引入db.properties配置文件 -->
<!-- <context:property-placeholder location="classpath:db.properties"/> -->
<!-- 5.配置数据源 -->
<!--
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
<!-- 这里报错说明类中不存在这个属性,需要改成规定的属性名 -->
<property name="driverClassName" value="${driver}"></property>
<property name="url" value="${url}"></property>
<property name="username" value="${user}"></property>
<property name="password" value="${password}"></property>
<property name="driverClassName" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${user}"/>
<property name="password" value="${password}"/>
<property name="initialSize" value="5"/>
<property name="maxTotal" value="20"/>
<property name="maxIdle" value="10"/>
<property name="minIdle" value="5"/>
</bean>
-->
<!-- 事务管理器DataSourceTransactionManager该类在spring-jdbc包中指定这个事务管理器管理配置的dataSource数据源 -->
<!-- <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean> -->
<!-- 开启基于注解的事务 -->
<!-- <tx:annotation-driven transaction-manager="dataSourceTransactionManager"/> -->
<!-- 6.配置MyBatis的SqlSessionFactory -->
<!--
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations" value="classpath:com/ssm/mapper/*.xml"/>
<property name="typeAliasesPackage" value="com.ssm.entity"/>
</bean>
-->
<!-- 4.整合mybatis配置:创建MyBatis核心对象SqlSessionFactory整合关键步骤
目的:(1)想让Spring管理所有组件包括mapper
以后Service层要调用Dao层时只需使用@Autowired注解自动注入即可。
这样就避免了每次操作增删改查之前需要先获取到SqlSessionFactory->SqlSession->getMapper方法获得动态代理对象
即接口类的对象,然后才能操作具体增删改查操作。
(2)Spring声明式事务非常强大想让Spring管理事务。
注意①SqlSessionFactoryBean类能创建出SqlSessionFactory对象意味着容器一启动让容器帮我们创建SqlSessionFactory-->
<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 访问数据库必然需要数据源,管理数据库的连接,提高数据库性能,在数据源中配置使用的连接池 -->
<property name="dataSource" ref="dataSource"></property>
<!-- 加载MyBatis全局配置文件config.xml如果config.xml中没有东西可以删掉
但一般建议留下可以放一些不太常用的配置如全局参数settings、数据库提供厂商等配置 -->
<!-- <property name="configLocation" value="classpath:config.xml"></property> -->
<!-- 指定SQL映射文件的位置当SQL映射文件和接口名不一致时使用该方法指定。
(不讲)?如果名字一致,则可以使用<mybatis:scan base-package=""/>扫描所有mapper SQL映射文件(报错mybatis前缀未绑定)? -->
<property name="mapperLocations" value="classpath:com/ssm/mapper/*.xml"></property>
<!-- 此处还可以配置别名处理器等,这些以前都是在全局配置文件中定义的现在都变成sqlSessionFactoryBean的一个属性,
相当于mybatis全局配置文件中的内容都拿到Spring配置文件来配置。 -->
<!-- 7.扫描Mapper接口自动生成代理对象 -->
<!-- 需要在Mapper接口上添加@Mapper注解或使用@MapperScan -->
<!--
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.ssm.mapper"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
-->
<!-- 5.扫描所有的mapper接口类让这些mapper能够自动注入
base-package:指定mapper接口的包名
注意:① 查找类路径下的映射器并自动将它们创建成MapperFactoryBean
即扫描所有的mapper接口类让这些mapper能够自动注入
② 如果有红叉报错也可以用,是约束引入有问题,不影响;
③ 以前还有这种写法(老版的项目一般这么做):
a.使用MapperScannerConfigurer
<bean class="MapperScannerConfigurer">
<property name="basePackage" value="Dao接口包名"/>
<bean> 或者
b.采用实体DAO调用方式采用接口org.apache.ibatis.session.SqlSession的实现类org.mybatis.spring.SqlSessionTemplate
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory"></constructor-arg>
</bean>
<!-- 8.配置事务管理器 -->
<!--
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
-->
<mybatis-spring:scan base-package="com.ssm.mapper"/>
<!-- 9.启用注解式事务 -->
<!-- 在Service方法上使用@Transactional注解 -->
<!-- <tx:annotation-driven transaction-manager="transactionManager"/> -->
</beans>

@ -4,7 +4,6 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 配置Patient实体类的Bean -->
<bean id="patient" class="com.ssm.ioc.Patient">
<property name="patientId" value="1001"/>
<property name="patientName" value="张三"/>
@ -14,7 +13,6 @@
<property name="address" value="北京市朝阳区建国路100号"/>
</bean>
<!-- 配置Doctor实体类的Bean -->
<bean id="doctor" class="com.ssm.ioc.Doctor">
<property name="doctorId" value="2001"/>
<property name="doctorName" value="李医生"/>
@ -24,7 +22,6 @@
<property name="email" value="li.doctor@hospital.com"/>
</bean>
<!-- 配置Department实体类的Bean -->
<bean id="department" class="com.ssm.ioc.Department">
<property name="deptId" value="3001"/>
<property name="deptName" value="内科"/>
@ -34,7 +31,6 @@
<property name="description" value="内科是医院的核心科室,负责常见疾病的诊断和治疗"/>
</bean>
<!-- 配置Appointment实体类的Bean -->
<bean id="appointment" class="com.ssm.ioc.Appointment">
<property name="appointmentId" value="4001"/>
<property name="patientName" value="张三"/>
@ -44,4 +40,77 @@
<property name="status" value="已预约"/>
</bean>
</beans>
<bean id="medicine" class="com.ssm.ioc.Medicine">
<property name="medicineId" value="5001"/>
<property name="medicineName" value="阿莫西林"/>
<property name="specification" value="0.5g*20粒"/>
<property name="manufacturer" value="华北制药"/>
<property name="price" value="25.5"/>
<property name="type" value="抗生素"/>
<property name="description" value="用于治疗细菌感染"/>
</bean>
<bean id="registration" class="com.ssm.ioc.Registration">
<property name="registrationId" value="6001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="doctorName" value="李医生"/>
<property name="doctorId" value="2001"/>
<property name="department" value="内科"/>
<property name="registrationDate" value="2026-04-14"/>
<property name="status" value="已挂号"/>
</bean>
<bean id="medicalRecord" class="com.ssm.ioc.MedicalRecord">
<property name="recordId" value="7001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="doctorName" value="李医生"/>
<property name="doctorId" value="2001"/>
<property name="diagnosis" value="上呼吸道感染"/>
<property name="symptoms" value="发热、咳嗽、咽痛"/>
<property name="treatment" value="口服阿莫西林每日三次每次2粒"/>
<property name="recordDate" value="2026-04-14"/>
</bean>
<bean id="medicalOrder" class="com.ssm.ioc.MedicalOrder">
<property name="orderId" value="8001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="doctorName" value="李医生"/>
<property name="doctorId" value="2001"/>
<property name="medicineName" value="阿莫西林"/>
<property name="medicineId" value="5001"/>
<property name="dosage" value="0.5g"/>
<property name="frequency" value="每日三次"/>
<property name="usage" value="口服"/>
<property name="orderDate" value="2026-04-14"/>
<property name="status" value="已执行"/>
</bean>
<bean id="hospitalization" class="com.ssm.ioc.Hospitalization">
<property name="hospitalizationId" value="9001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="orderId" value="8001"/>
<property name="department" value="内科"/>
<property name="roomNo" value="301"/>
<property name="bedNo" value="01"/>
<property name="admitDate" value="2026-04-14"/>
<property name="dischargeDate" value="2026-04-20"/>
<property name="status" value="住院中"/>
</bean>
<bean id="expense" class="com.ssm.ioc.Expense">
<property name="expenseId" value="10001"/>
<property name="orderId" value="8001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="expenseType" value="药品费"/>
<property name="amount" value="25.5"/>
<property name="description" value="阿莫西林药费"/>
<property name="expenseDate" value="2026-04-14"/>
<property name="status" value="已结算"/>
</bean>
</beans>

@ -1,4 +1,4 @@
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/ssm_farm?serverTimezone=Asia/Shanghai
url=jdbc:mysql://localhost:3306/ssm_farm?useSSL=false&serverTimezone=Asia/Shanghai
user=root
password=root

@ -9,33 +9,43 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd">
<!-- 配置扫描器
只扫描标了@Controller的控制器
use-default-filters="false"禁用掉默认的过滤行为,只包含才会生效。即:
<context:component-scan base-package="com.ssm" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan> -->
<!-- <context:component-scan base-package="com.ssm"></context:component-scan> -->
<context:component-scan base-package="com.ssm" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- 视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"></property> <!-- 前缀 -->
<property name="suffix" value=".jsp"></property> <!-- 后缀 -->
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
<property name="contentType" value="text/html;charset=UTF-8"></property>
</bean>
<!-- 处理动态资源是SpringMVC的基础配置可以协调很多功能一般写SpringMVC项目都加上 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 正确的处理静态资源 -->
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value="text/html;charset=UTF-8"/>
</bean>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
</mvc:message-converters>
</mvc:annotation-driven>
<mvc:default-servlet-handler/>
<bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<mvc:resources mapping="/static/**" location="/static/"/>
<mvc:resources mapping="/css/**" location="/css/"/>
<mvc:resources mapping="/js/**" location="/js/"/>
<mvc:resources mapping="/images/**" location="/images/"/>
<bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
</bean>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize">
<value>5242880</value>
</property>
<property name="maxUploadSize" value="5242880"/>
<property name="defaultEncoding" value="UTF-8"/>
</bean>
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="defaultErrorView" value="error"/>
<property name="exceptionAttribute" value="exception"/>
</bean>
</beans>
</beans>

@ -1,64 +0,0 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler
# For example, set the org.apache.catalina.util.LifecycleBase logger to log
# each component that extends LifecycleBase changing state:
#org.apache.catalina.util.LifecycleBase.level = FINE
# To see debug messages in TldLocationsCache, uncomment the following line:
#org.apache.jasper.compiler.TldLocationsCache.level = FINE

@ -1,26 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<tomcat-users>
<!--
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
-->
</tomcat-users>

File diff suppressed because it is too large Load Diff

@ -50,6 +50,16 @@
function refresh() {
window.location.href = "${pageContext.request.contextPath}/demo/findAllByPage.action?page=1";
}
$(function() {
$('.refresh-btn').click(function() {
refresh();
});
$('.submit-btn').click(function() {
edit();
});
});
</script>
</head>
<body>
@ -59,7 +69,7 @@
</div>
<div align="right" style="padding-right: 60px; padding-top: 20px;">
<input class="btn btn-info" type="button" onclick="refresh()"
<input class="btn btn-info refresh-btn" type="button"
value="返回" style="margin-left: 600px;" align="right" />
</div>
</div>
@ -89,7 +99,7 @@
<td></td>
<td align="center">
<button type="submit" id="userAction_save_do_submit" value="提交"
class="btn btn-primary" onclick="edit()">&#30830;&#23450;</button>
class="btn btn-primary submit-btn">&#30830;&#23450;</button>
</td>
</tr>

@ -26,27 +26,29 @@
<script type="text/javascript">
var basepath= '${APP_PATH}';
var ctx = "${pageContext.request.contextPath}";
function refresh(){
window.location.href = "${pageContext.request.contextPath}/demo/findAllByPage.action?page=1";
window.location.href = ctx + "/demo/findAllByPage.action?page=1";
}
function addDemo(){
window.location.href = "${pageContext.request.contextPath}/demo/add.action";
window.location.href = ctx + "/demo/add.action";
}
function edit(did) {
window.location.href = "${pageContext.request.contextPath}/demo/updateById.action?did="+did;
function goEdit(did) {
window.location.href = ctx + "/demo/updateById.action?did=" + did;
}
function deletecs(did) {
var r=confirm("确定删除吗?");
if (r==true){
window.location.href = "${pageContext.request.contextPath}/demo/deleteById.action?did="+did;
}
else{
function goDelete(did) {
var r = confirm("确定删除吗?");
if (r == true){
window.location.href = ctx + "/demo/deleteById.action?did=" + did;
}
}
function look(did) {
window.location.href = "${pageContext.request.contextPath}/demo/findById.action?did="+did;
function goLook(did) {
window.location.href = ctx + "/demo/findById.action?did=" + did;
}
function validate() {
@ -57,6 +59,37 @@
}
return true;
}
$(function() {
$('.btn-edit').click(function() {
var id = $(this).data('id');
goEdit(id);
});
$('.btn-view').click(function() {
var id = $(this).data('id');
goLook(id);
});
$('.btn-delete').click(function() {
var id = $(this).data('id');
goDelete(id);
});
$('.search-btn').click(function(e) {
if (!validate()) {
e.preventDefault();
}
});
$('.add-btn').click(function() {
addDemo();
});
$('.refresh-btn').click(function() {
refresh();
});
});
</script>
</head>
@ -69,51 +102,41 @@
value="请输入关键词" onfocus="this.value = '';"
onblur="if (this.value == '') {this.value = '请输入关键词';}">&nbsp;&nbsp;
<button type="submit"
class="btn btn-primary btn-sm glyphicon glyphicon-search"
onclick="validate()"></button>
<button type="submit" class="search-btn">搜索</button>
</form>
</div>
<div align="right" style="padding-right: 30px;">
<input type="button" value="+添加demo" class="btn btn-primary"
onclick="addDemo()" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button type="button" onclick="refresh()"
class="btn glyphicon glyphicon-refresh"></button>
<div>
<button type="button" class="add-btn">+ 添加demo</button>
<button type="button" class="refresh-btn">↻</button>
</div>
</div>
<div class="d" style="width: 96%; margin-left: 25px;">
<!-- 显示结果 -->
<form style="margin-top: 3px;">
<table width="100%" align="center"
class="table table-hover table-striped" id="table"
style="border: 1px solid #D0D0D0">
<table class="data-table">
<thead>
<tr align="center" bgcolor="#93b6bd" height="33px;">
<th scope="col" style="text-align: center;">demoID</th>
<th scope="col" style="text-align: center;">demo名</th>
<th scope="col" style="text-align: center;">备注</th>
<th scope="col" style="text-align: center;">操作</th>
<tr>
<th scope="col">demoID</th>
<th scope="col">demo名</th>
<th scope="col">备注</th>
<th scope="col">操作</th>
</tr>
</thead>
<!-- <tbody></tbody> -->
<c:forEach items="${allProPageBean.list }" var="d"
<c:forEach items="${allProPageBean.list}" var="d"
varStatus="status">
<tr height="30">
<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="5%">${d.did}</td>
<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="15%">${d.dname }</td>
<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="15%">${d.comment }</td>
<tr>
<td><c:out value="${d.did}" /></td>
<td><c:out value="${d.dname}" /></td>
<td><c:out value="${d.comment}" /></td>
<td>
<button type="button"
class="btn btn-primary btn-sm glyphicon glyphicon-pencil"
onclick="edit(${d.did})"></button>&nbsp;
<button type="button"
class="btn btn-success btn-sm glyphicon glyphicon-asterisk"
onclick="look(${d.did})"></button>
<button type="button"
class="btn btn-success btn-sm glyphicon glyphicon-trash"
onclick="deletecs(${d.did})"></button>
<div class="btn-group">
<button type="button" class="btn btn-edit" data-id="<c:out value="${d.did}" />">编辑</button>
<button type="button" class="btn btn-view" data-id="<c:out value="${d.did}" />">查看</button>
<button type="button" class="btn btn-delete" data-id="<c:out value="${d.did}" />">删除</button>
</div>
</td>
</tr>
</c:forEach>
@ -123,14 +146,11 @@
<!-- 分页 -->
<div align="right"
style="padding-right: 40px; margin-bottom: 10px; font-size: 13px;">
第${allProPageBean.page }/${allProPageBean.totlePage}页
<div class="pagination">
<span class="pagination-info">第 ${allProPageBean.page} / ${allProPageBean.totlePage} 页</span>
<c:if test="${allProPageBean.page!= 1}">
<a style="font-size: 13px;"
href="${pageContext.request.contextPath }/demo/findAllByPage.action?page=1">首页</a>|
<a style="font-size: 13px;"
href="${pageContext.request.contextPath }/demo/findAllByPage.action?page=${allProPageBean.page-1}">上一页</a>
<a class="page-link" href="${pageContext.request.contextPath }/demo/findAllByPage.action?page=1">首页</a>|
<a class="page-link" href="${pageContext.request.contextPath }/demo/findAllByPage.action?page=${allProPageBean.page-1}">上一页</a>
</c:if>
<c:choose>
@ -157,8 +177,7 @@
<c:forEach var="i" begin="${begin}" end="${end}">
<c:choose>
<c:when test="${allProPageBean.page!=i}">
<a style="font-size: 13px;"
href="${ pageContext.request.contextPath }/product/findAllByPage.action?page=${i}">${i}</a>
<a class="page-link" href="${ pageContext.request.contextPath }/demo/findAllByPage.action?page=${i}">${i}</a>
</c:when>
<c:otherwise>
<span class="currentPage">${i}</span>
@ -166,14 +185,11 @@
</c:choose>
</c:forEach>
<c:if test="${allProPageBean.page!= allProPageBean.totlePage }">
<a style="font-size: 13px;"
href="${pageContext.request.contextPath }/demo/findAllByPage.action?page=${allProPageBean.page+1}">下一页</a> |
<a style="font-size: 13px;"
href="${pageContext.request.contextPath }/demo/findAllByPage.action?page=${allProPageBean.totlePage }">尾页</a>
<c:if test="${allProPageBean.page!= allProPageBean.totlePage}">
<a class="page-link" href="${pageContext.request.contextPath }/demo/findAllByPage.action?page=${allProPageBean.page+1}">下一页</a> |
<a class="page-link" href="${pageContext.request.contextPath }/demo/findAllByPage.action?page=${allProPageBean.totlePage}">尾页</a>
</c:if>
</div>
</body>
</html>
</html>

@ -53,6 +53,43 @@ function ret() {
function refresh(){
window.location.href = "${pageContext.request.contextPath}/demo/findAllByPage.action?page=1";
}
function validate() {
var condition = document.getElementById("condition").value;
if (condition == null || condition == '') {
alert("请输入关键字");
return false;
}
return true;
}
$(function() {
$('.btn-edit').click(function() {
edit($(this).data('id'));
});
$('.btn-view').click(function() {
look($(this).data('id'));
});
$('.btn-delete').click(function() {
deletecs($(this).data('id'));
});
$('.search-btn').click(function(e) {
if (!validate()) {
e.preventDefault();
}
});
$('.add-btn').click(function() {
addDemo();
});
$('.refresh-btn').click(function() {
refresh();
});
});
</script>
</head>
@ -65,16 +102,14 @@ function refresh(){
value="请输入关键词" onfocus="this.value = '';"
onblur="if (this.value == '') {this.value = '请输入关键词';}">&nbsp;&nbsp;
<button type="submit"
class="btn btn-primary btn-sm glyphicon glyphicon-search"
onclick="validate()"></button>
class="btn btn-primary btn-sm glyphicon glyphicon-search validate-btn"></button>
</form>
</div>
<div align="right" style="padding-right: 30px;">
<input type="button" value="+添加demo" class="btn btn-primary"
onclick="addDemo()" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button type="button" onclick="refresh()"
class="btn glyphicon glyphicon-refresh"></button>
<input type="button" value="+添加demo" class="btn btn-primary add-demo-btn" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button type="button"
class="btn glyphicon glyphicon-refresh refresh-btn"></button>
</div>
</div>
@ -99,11 +134,11 @@ function refresh(){
<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="17%">${d.comment}</td>
<td>
<button type="button"
class="btn btn-primary btn-sm glyphicon glyphicon-pencil"
onclick="edit(${d.did})"></button>&nbsp;
<button type="button"
class="btn btn-success btn-sm glyphicon glyphicon-asterisk"
onclick="look(${d.did})"></button>
class="btn btn-primary btn-sm glyphicon glyphicon-pencil btn-edit"
data-id="${d.did}"></button>&nbsp;
<button type="button"
class="btn btn-success btn-sm glyphicon glyphicon-asterisk btn-view"
data-id="${d.did}"></button>
</td>
</tr>
</c:forEach>

@ -11,10 +11,10 @@ body {
}
</style>
</head>
<frameset rows="56,*,10" frameborder=1 border="1" framespacing="1">
<frameset rows="70,*,0" frameborder=0 border=0 framespacing="0">
<frame src="${pageContext.request.contextPath}/jsp/top.jsp"
name="topFrame" scrolling="NO" noresize>
<frameset cols="159,*">
<frameset cols="200,*">
<frame src="${pageContext.request.contextPath}/jsp/left.jsp"
name="leftFrame" noresize scrolling="YES">
<frame src="${pageContext.request.contextPath}/jsp/right.jsp"

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>hospital</display-name>
<welcome-file-list>
<welcome-file>admin.action</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>admin</welcome-file>
</welcome-file-list>
<!-- 1.Spring配置文件让Spring在web项目中起作用让Spring IoC容器跟随项目一起启动 -->
@ -45,6 +47,10 @@
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>

@ -1,590 +1,213 @@
@charset "UTF-8";
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #FFFFFF;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background: linear-gradient(135deg, #f9fafb 0%, #e5e7eb 100%);
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
color: #1f2937;
}
td,select {
font-size: 12px;
td, select {
font-size: 14px;
color: #374151;
}
A.cl:link {
font-size:12px;
color: #000000;
text-decoration:none;
font-size: 14px;
color: #3b82f6;
text-decoration: none;
transition: all 0.2s ease;
}
A.cl:visited {
font-size:12px;
color: #000000;
text-decoration:none;
font-size: 14px;
color: #3b82f6;
text-decoration: none;
}
A.cl:hover {
font-size:12px;
color: #cc0000;
text-decoration:underline;
font-size: 14px;
color: #1d4ed8;
text-decoration: underline;
}
A.cl_01:link {
font-size:12px;
color: #000066;
text-decoration:none;
.top {
padding: 18px 32px;
font-weight: 700;
font-size: 24px;
background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
color: #ffffff;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
letter-spacing: 1px;
}
A.cl_01:visited {
font-size:12px;
color: #000066;
text-decoration:none;
.bt_01 {
line-height: 1.6;
color: #ffffff;
padding-left: 20px;
padding-bottom: 12px;
}
A.cl_01:hover {
font-size:12px;
color: #0066CC;
text-decoration:underline;
.button {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
margin: 4px;
padding: 8px 20px;
border: none;
color: #ffffff;
cursor: pointer;
border-radius: 8px;
font-weight: 600;
font-size: 14px;
transition: all 0.2s ease;
box-shadow: 0 4px 6px -1px rgba(102, 126, 234, 0.3);
}
.bt_01 {
line-height: 155%;
color: #FFFFFF;
padding-left: 15px;
padding-bottom: 10px;
}
.box04 {
font-size: 12px;
padding-top: 7px;
padding-left: 16px;
background-color: #88A5DF;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #7798DC;
border-right-color: #2C416B;
border-bottom-color: #2C416B;
border-left-color: #7798DC;
padding-bottom: 4px;
}
.box01 {
font-size: 12px;
color: #000000;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #EDF8FF;
border-right-color: #8099B2;
border-bottom-color: #8099B2;
border-left-color: #EDF8FF;
background-color: #B2CFED;
padding-top: 7px;
padding-left: 16px;
border-top-style: solid;
padding-bottom: 4px;
}
.box05 {
font-size: 12px;
padding-top: 5px;
padding-left: 30px;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #B2CFED;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #F4F9FF;
padding-bottom: 3px;
background-color: #EDF8FF;
}
.box06 {
font-size: 12px;
background-color: #EDF6FF;
padding-top: 5px;
padding-left: 30px;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #ADAEAD;
padding-bottom: 3px;
.button:hover {
transform: translateY(-2px);
box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}
.bottom {
color: #000066;
.button_ok, .button_save {
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
color: #ffffff;
box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}
A.cl_02:link {
font-size:12px;
color: #CC0000;
text-decoration:underline;
.button_cancel, .button_close {
background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
color: #ffffff;
box-shadow: 0 4px 6px -1px rgba(107, 114, 128, 0.3);
}
A.cl_02:visited {
font-size:12px;
color: #CC0000;
text-decoration:underline;
.button_del {
background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
color: #ffffff;
box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.3);
}
A.cl_02:hover {
font-size:12px;
color: #CC0000;
text-decoration:none;
.button_add {
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
color: #ffffff;
box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}
.top {
padding-top: 4px;
padding-bottom: 2px;
font-weight: bold;
background-color: #AFD1F3;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #E3EFFB;
border-right-color: #7990A8;
border-bottom-color: #7990A8;
border-left-color: #E3EFFB;
}
.ta_01 {
padding-top: 4px;
padding-bottom: 2px;
padding-right: 2px;
padding-left: 3px;
line-height: 135%;
.button_modi {
background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
color: #ffffff;
box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.3);
}
A:link {
font-size:12px;
color: #000000;
text-decoration:none;
.button_search {
background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
color: #ffffff;
box-shadow: 0 4px 6px -1px rgba(139, 92, 246, 0.3);
}
A:visited {
font-size:12px;
color: #000000;
text-decoration:none;
}
A.eq:hover {
font-size:12px;
color: #0066FF;
text-decoration:underline;
}
A.eq:link {
font-size:12px;
color: #000000;
text-decoration:underline;
}
A.eq:visited {
font-size:12px;
color: #000000;
text-decoration:underline;
}
A.eq:hover {
font-size:12px;
color: #0066FF;
text-decoration:underline;
.button_view {
background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
color: #ffffff;
box-shadow: 0 4px 6px -1px rgba(6, 182, 212, 0.3);
}
.bg {
border-top:0px ;
border-left:0px ;
border-right:0px ;
border-bottom: solid 1px gray;
background-color: #FBFDFF;
height:21px ;
width:150px;
.box01, .box04 {
font-size: 14px;
padding: 12px 24px;
background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
border: 1px solid #e5e7eb;
border-radius: 12px;
margin: 12px;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}
.button {
background-color: #DAE6FF;
margin: 1px;
padding: 0px 2px 0px 2px;
border: 1px solid #8AA2CC;
color: #333333;
cursor: hand;
/*
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
*/
height: 18px;
}
.button_ok {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_ok.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
}
.button_cancel {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_cancel.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
}
.button_help {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_help.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
}
.button_exit {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_search.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
.button_search {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_exit.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
.box05, .box06 {
font-size: 14px;
padding: 10px 24px;
border-bottom: 1px solid #e5e7eb;
background: #ffffff;
}
.button_view {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_view.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
.bg {
border: 2px solid #e5e7eb;
border-radius: 8px;
background-color: #ffffff;
height: 36px;
width: 180px;
padding: 0 12px;
transition: all 0.2s ease;
}
.button_add {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_add.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
.bg:focus {
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
outline: none;
}
.button_del {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_del.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
}
.button_print {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_print.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
.grouptitle {
background: linear-gradient(135deg, #f9fafb 0%, #e5e7eb 100%);
color: #667eea;
font-weight: 600;
padding: 12px 20px;
border-radius: 8px;
margin: 8px 0;
}
.button_modi {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_modi.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
}
.button_save {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_save.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
}
.button_alert {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_alert.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
}
.button_clock {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_clock.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
}
.button_close {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_close.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
}
.button_phone01 {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/button_phone01.gif);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
}
.button_dire {
background-color: #DAE6FF;
margin: 1px;
padding: 2px 4px 2px 10px;
border: 1px solid #8AA2CC;
background-attachment: fixed;
background-image: url(../images/hotel_dire_arrowc.jpg);
background-repeat: no-repeat;
background-position: left center;
color: #2F3F5B;
cursor: hand;
text-align: right;
left: 10px;
top: 10px;
right: 0px;
bottom: 10px;
clip: rect(10px 10px 10px 10px);
height: 20px;
}
.NextLine
{
word-break:break-all;word-wrap:break-word;
}
.test
{
BACKGROUND-IMAGE: url(../images/aaa.gif); HEIGHT: 25px;
}
.optionOff
{
color:#909090;
background-image:url(../images/optionbgOff.gif);
background-position:right;
background-repeat:no-repeat;
border-left:1px solid #a0a0a0;
text-align:center;
width:110px;
cursor:hand;
}
.optionOn {
color:#1E6BAE;
background-image:url(../images/optionbgOn.gif);
background-position:right;
background-repeat:no-repeat;
border-left:1px solid #808080;
text-align:center;
font-weight:bold;
width:110px;
cursor:hand;
}
.optionOff A,.optionOff A:link,.optionOff A:visited,.optionOff A:hover,.optionOff A:active {
color:#909090;
text-decoration:none;
}
.optionOn A,.optionOn A:link,.optionOn A:visited,.optionOn A:hover,.optionOn A:active {
color:#1E6BAE;
text-decoration:none;
.sep1 {
padding: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
height: 4px;
border-radius: 2px;
margin: 16px 0;
}
.NextLine {
word-break: break-all;
word-wrap: break-word;
}
.tbodyhidden {
display:none;
display: none;
}
.xscroll {
overflow-x:auto;
height:auto;
SCROLLBAR-FACE-COLOR: #E0F0FC;
SCROLLBAR-SHADOW-COLOR: #EAF5FD;
SCROLLBAR-3DLIGHT-COLOR: #808080;
SCROLLBAR-ARROW-COLOR: #808080;
SCROLLBAR-DARKSHADOW-COLOR:#808080;
buttonface: #666666;
overflow-x: auto;
height: auto;
}
.xscrollhidden {
overflow-x:auto;
display:none;
SCROLLBAR-FACE-COLOR: #E0F0FC;
SCROLLBAR-SHADOW-COLOR: #EAF5FD;
SCROLLBAR-3DLIGHT-COLOR: #808080;
SCROLLBAR-ARROW-COLOR: #808080;
SCROLLBAR-DARKSHADOW-COLOR:#808080;
buttonface: #666666;
overflow-x: auto;
display: none;
}
.sep1 {
padding:0px;
background-color:#AFD1F3;
.bodyscroll {
overflow-y: auto;
}
.grouptitle {
background-color:#E0F0FC;
color: #5580D7;
.bottom {
color: #4b5563;
padding: 16px 24px;
background: #f9fafb;
border-top: 1px solid #e5e7eb;
}
.bodyscroll {
SCROLLBAR-FACE-COLOR: #f6f6f6;
SCROLLBAR-SHADOW-COLOR: #8099B2;
SCROLLBAR-3DLIGHT-COLOR: #8099B2;
SCROLLBAR-ARROW-COLOR: #8099B2;
SCROLLBAR-DARKSHADOW-COLOR:#cccccc;
buttonface: #f6f6f6;
A:link {
font-size: 14px;
color: #3b82f6;
text-decoration: none;
transition: all 0.2s ease;
}
A:visited {
font-size: 14px;
color: #3b82f6;
text-decoration: none;
}
A:hover {
color: #1d4ed8;
}

@ -1,29 +1,49 @@
.dtree {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #fff;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
font-size: 14px;
color: #e5e7eb;
white-space: nowrap;
padding: 12px;
}
.dtree img {
border: 0px;
vertical-align: middle;
margin-right: 8px;
}
.dtree a {
color: #333;
color: #a5b4fc;
text-decoration: none;
transition: all 0.2s ease;
}
.dtree a.node, .dtree a.nodeSel {
white-space: nowrap;
padding: 1px 2px 1px 2px;
padding: 10px 16px;
border-radius: 8px;
display: inline-block;
margin: 4px 0;
width: 100%;
box-sizing: border-box;
}
.dtree a.node:hover, .dtree a.nodeSel:hover {
color: #333;
text-decoration: underline;
.dtree a.node:hover {
color: #ffffff;
background: rgba(102, 126, 234, 0.2);
}
.dtree a.nodeSel {
background-color: #fff;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #ffffff;
font-weight: 600;
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.dtree a.nodeSel:hover {
color: #ffffff;
}
.dtree .clip {
overflow: hidden;
}
}

@ -1,67 +1,298 @@
@CHARSET "UTF-8";
@charset "UTF-8";
table {
border-collapse: collapse; /* 合并为单一的边框线 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
table.tb td {
padding: 7px;
/* border: 1px solid green; */
border: 1px solid #D1D1D1;
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
color: #1f2937;
font-size: 14px;
padding: 20px;
}
.a {
height: 20px;
margin-top: 20px;
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
border-radius: 16px;
padding: 24px 32px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
margin-bottom: 24px;
border: 1px solid rgba(255, 255, 255, 0.2);
}
.b {
float: left;
margin-left: 50px;
display: flex;
align-items: center;
gap: 16px;
}
.c {
float: left;
padding-left: 490px;
.input1 {
height: 44px;
width: 320px;
border: 2px solid #e5e7eb;
border-radius: 12px;
padding: 0 18px;
font-size: 15px;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
outline: none;
background: #f9fafb;
}
.input1:focus {
border-color: #667eea;
background: #ffffff;
box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
transform: translateY(-1px);
}
.search-btn {
height: 44px;
padding: 0 28px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #fff;
border: none;
border-radius: 12px;
cursor: pointer;
font-size: 15px;
font-weight: 600;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
}
.search-btn:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}
.search-btn:active {
transform: translateY(0);
}
.add-btn {
height: 44px;
padding: 0 28px;
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
color: #fff;
border: none;
border-radius: 12px;
cursor: pointer;
font-size: 15px;
font-weight: 600;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
display: flex;
align-items: center;
gap: 8px;
box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}
.add-btn:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5);
}
.add-btn:active {
transform: translateY(0);
}
.refresh-btn {
height: 44px;
width: 44px;
background: #ffffff;
border: 2px solid #e5e7eb;
border-radius: 12px;
cursor: pointer;
color: #6b7280;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
}
.refresh-btn:hover {
background: #f9fafb;
color: #667eea;
border-color: #667eea;
transform: rotate(180deg);
}
.d {
margin-top: 28px;
/* background-color: #ECF5FF; */
width: 97%;
margin-left: 16px;
text-align: center;
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
overflow: hidden;
border: 1px solid rgba(255, 255, 255, 0.2);
}
.input1 {
height: 30px;
border-radius: 8px;
}
.input2 {
height: 38px;
width: 69px;
background-color: #0f83c7;
color: white;
border-radius: 8px;
font-size: 14px;
}
.input3 {
height: 38px;
width: 75px;
margin-left: 14px;
background-color: #0f83c7;
color: white;
border-radius: 8px;
font-size: 14px;
}
.c td input {
height: 38px;
width: 90px;
background-color: #149ff0;
color: white;
border-radius: 8px;
font-size: 14px;
}
.table-container {
padding: 32px;
}
.data-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
background: #ffffff;
border-radius: 16px;
overflow: hidden;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.data-table thead tr {
background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
}
.data-table thead th {
padding: 18px 16px;
text-align: center;
font-weight: 600;
font-size: 14px;
color: #ffffff;
text-transform: uppercase;
letter-spacing: 0.5px;
border: none;
}
.data-table tbody tr {
border-bottom: 1px solid #f3f4f6;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.data-table tbody tr:hover {
background: linear-gradient(90deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
transform: scale(1.005);
}
.data-table tbody tr:last-child {
border-bottom: none;
}
.data-table tbody td {
padding: 18px 16px;
text-align: center;
font-size: 14px;
color: #4b5563;
font-weight: 400;
}
.data-table tbody td:first-child {
color: #667eea;
font-weight: 600;
}
.btn-group {
display: flex;
justify-content: center;
gap: 10px;
align-items: center;
}
.btn {
padding: 10px 20px;
border: none;
border-radius: 10px;
cursor: pointer;
font-size: 14px;
font-weight: 600;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
margin: 0 3px;
min-width: 80px;
letter-spacing: 0.3px;
}
.btn:first-child {
margin-left: 0;
}
.btn:last-child {
margin-right: 0;
}
.btn-edit {
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
color: #fff;
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.btn-edit:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}
.btn-view {
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
color: #fff;
box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-view:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}
.btn-delete {
background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
color: #fff;
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.btn-delete:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}
.pagination {
display: flex;
justify-content: flex-end;
align-items: center;
padding: 24px 32px;
gap: 10px;
background: #f9fafb;
border-top: 1px solid #f3f4f6;
}
.pagination-info {
color: #6b7280;
font-size: 14px;
margin-right: 16px;
font-weight: 500;
}
.page-link {
padding: 10px 16px;
border: 2px solid #e5e7eb;
border-radius: 10px;
text-decoration: none;
color: #4b5563;
font-size: 14px;
font-weight: 500;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
background: #ffffff;
}
.page-link:hover {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #fff;
border-color: transparent;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.currentPage {
padding: 10px 16px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #fff;
border-radius: 10px;
font-size: 14px;
font-weight: 600;
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

@ -1,4 +1,66 @@
body {background-color: #fff;margin: 0px;text-align:left;}
td {font-size:12px;color:#303030;line-height:20px;}
a:link,a:visited {color:#012F68;text-decoration: none;}
a:hover {color: #406EA8;text-decoration:none}
@charset "UTF-8";
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
margin: 0;
text-align: left;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
min-height: 100vh;
}
td {
font-size: 14px;
color: #f3f4f6;
line-height: 1.6;
}
a:link, a:visited {
color: #a5b4fc;
text-decoration: none;
transition: all 0.3s ease;
}
a:hover {
color: #ffffff;
text-decoration: none;
}
.tree {
padding: 20px 16px;
}
.treeNode {
padding: 10px 16px;
margin: 4px 0;
border-radius: 10px;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
cursor: pointer;
}
.treeNode:hover {
background: rgba(102, 126, 234, 0.2);
transform: translateX(4px);
}
.treeNode.selected {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #ffffff;
font-weight: 600;
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.treeNode a {
color: #e5e7eb;
font-size: 14px;
font-weight: 500;
}
.treeNode.selected a {
color: #ffffff;
}

@ -61,33 +61,33 @@ function dTree(objName) {
this.icon = {
root : '../images/tree/base.gif',
root : '/hospital/images/tree/base.gif',
folder : '../images/tree/folder.gif',
folder : '/hospital/images/tree/folder.gif',
folderOpen : '../images/tree/folderopen.gif',
folderOpen : '/hospital/images/tree/folderopen.gif',
node : '../images/tree/page.gif',
node : '/hospital/images/tree/page.gif',
empty : '../images/tree/empty.gif',
empty : '/hospital/images/tree/empty.gif',
line : '../images/tree/line.gif',
line : '/hospital/images/tree/line.gif',
join : '../images/tree/join.gif',
join : '/hospital/images/tree/join.gif',
joinBottom : '../images/tree/joinbottom.gif',
joinBottom : '/hospital/images/tree/joinbottom.gif',
plus : '../images/tree/plus.gif',
plus : '/hospital/images/tree/plus.gif',
plusBottom : '../images/tree/plusbottom.gif',
plusBottom : '/hospital/images/tree/plusbottom.gif',
minus : '../images/tree/minus.gif',
minus : '/hospital/images/tree/minus.gif',
minusBottom : '../images/tree/minusbottom.gif',
minusBottom : '/hospital/images/tree/minusbottom.gif',
nlPlus : '../images/tree/nolines_plus.gif',
nlPlus : '/hospital/images/tree/nolines_plus.gif',
nlMinus : '../images/tree/nolines_minus.gif'
nlMinus : '/hospital/images/tree/nolines_minus.gif'
};

@ -15,13 +15,23 @@
<script type="text/javascript" src="${pageContext.request.contextPath}/js/dtree.js"></script>
<script type="text/javascript">
d = new dTree('d');
d.add('01','-1','系统菜单');
d.add('0101','01','demo管理','','','mainFrame');
d.add('010101','0101','demo管理','${pageContext.request.contextPath}/demo/findAllByPage.action?page=1','','mainFrame');
d.add('0102','01','功能1','','','mainFrame');
d.add('010201','0102','功能1','${pageContext.request.contextPath}/1/findAll.action','','mainFrame');
d.add('0104','01','功能2','','','mainFrame');
d.add('010401','0104','功能2','${pageContext.request.contextPath}/2/findAllByPage.action?page=1','','mainFrame');
d.add('01','-1','医院诊疗系统');
d.add('0101','01','医生管理','','','mainFrame');
d.add('010101','0101','医生列表','${pageContext.request.contextPath}/doctor/findAllByPage.action?page=1','','mainFrame');
d.add('0102','01','患者管理','','','mainFrame');
d.add('010201','0102','患者列表','${pageContext.request.contextPath}/patient/findAllByPage.action?page=1','','mainFrame');
d.add('0103','01','药品管理','','','mainFrame');
d.add('010301','0103','药品列表','${pageContext.request.contextPath}/medicine/findAllByPage.action?page=1','','mainFrame');
d.add('0104','01','挂号管理','','','mainFrame');
d.add('010401','0104','挂号列表','${pageContext.request.contextPath}/registration/findAllByPage.action?page=1','','mainFrame');
d.add('0105','01','病历管理','','','mainFrame');
d.add('010501','0105','病历列表','${pageContext.request.contextPath}/medicalRecord/findAllByPage.action?page=1','','mainFrame');
d.add('0106','01','医嘱管理','','','mainFrame');
d.add('010601','0106','医嘱列表','${pageContext.request.contextPath}/medicalOrder/findAllByPage.action?page=1','','mainFrame');
d.add('0107','01','住院管理','','','mainFrame');
d.add('010701','0107','住院列表','${pageContext.request.contextPath}/hospitalization/findAllByPage.action?page=1','','mainFrame');
d.add('0108','01','费用管理','','','mainFrame');
d.add('010801','0108','费用列表','${pageContext.request.contextPath}/expense/findAllByPage.action?page=1','','mainFrame');
document.write(d);
</script>
</div>

@ -4,8 +4,41 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<title>医院诊疗系统</title>
<style>
body {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
min-height: 100vh;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
}
.welcome {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
padding: 60px 80px;
border-radius: 20px;
text-align: center;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
.welcome h1 {
color: #1f2937;
margin: 0 0 20px 0;
font-size: 32px;
}
.welcome p {
color: #6b7280;
font-size: 16px;
margin: 0;
}
</style>
</head>
<body style="background-color: #fff">
<body>
<div class="welcome">
<h1>🏥 欢迎使用医院诊疗系统</h1>
<p>请从左侧菜单选择功能模块</p>
</div>
</body>
</html>
</html>

@ -7,66 +7,54 @@
<title>top</title>
<style type="text/css">
body {
background-color: #1a2d40;
background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
color: white;
font-size: 18px;
font-weight: bold;
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 18px 32px;
height: 70px;
box-sizing: border-box;
}
.title {
font-size: 24px;
font-weight: 700;
letter-spacing: 1px;
}
.user-info {
font-size: 14px;
display: flex;
align-items: center;
gap: 16px;
}
.user-info a {
color: #a5b4fc;
text-decoration: none;
padding: 8px 16px;
border-radius: 8px;
transition: all 0.2s ease;
border: 1px solid rgba(165, 180, 252, 0.3);
}
.user-info a:hover {
background: rgba(165, 180, 252, 0.1);
color: #ffffff;
}
</style>
<script type="text/javascript">
function time() {
tmpDate = new Date();
date = tmpDate.getDate();
month = tmpDate.getMonth() + 1;
year = tmpDate.getFullYear();
document.write(year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日 ");
myArray = new Array(6);
myArray[0] = "星期日"
myArray[1] = "星期一"
myArray[2] = "星期二"
myArray[3] = "星期三"
myArray[4] = "星期四"
myArray[5] = "星期五"
myArray[6] = "星期六"
weekday = tmpDate.getDay();
if (weekday == 0 | weekday == 6) {
document.write(myArray[weekday])
} else {
document.write(myArray[weekday])
}
;
}
</script>
</head>
<body bgColor='#ffffff' style="margin: 0; padding: 0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="50">&nbsp;&nbsp;&nbsp;&nbsp;农产品销售系统平台</td>
<td width='50%' align="right">
<table width="750" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" height="26"
style="padding-right: 10px; line-height: 26px; font-size: 17px">
<font style="font-size: 12px; font-weight: bold;"> <s:if
test="#session.userType == '01'">
欢迎您,系统管理员&nbsp;&nbsp;&nbsp;&nbsp;
</s:if> <s:else>
您好:<font color="red">${adminuserLogin.username}</font>&nbsp;&nbsp;&nbsp;&nbsp;
</s:else>
</font>[<a href="${pageContext.request.contextPath}/"
target="_parent" style="color:white; font-size: 12px;">安全退出</a>]
</td>
</tr>
</table>
</td>
</tr>
</table>
<body style="margin: 0; padding: 0">
<div class="header">
<div class="title">🏥 医院诊疗系统</div>
<div class="user-info">
<span>
欢迎您,系统管理员
</span>
<a href="${pageContext.request.contextPath}/" target="_parent">安全退出</a>
</div>
</div>
</body>
</html>

@ -1,18 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd">
<context:component-scan base-package="com.ssm.controller"/>
<context:component-scan base-package="com.ssm" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
<property name="contentType" value="text/html;charset=UTF-8"></property>
</bean>
<mvc:annotation-driven/>
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value="text/html;charset=UTF-8"/>
</bean>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
</mvc:message-converters>
</mvc:annotation-driven>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/"/>
<property name="suffix" value=".jsp"/>
<mvc:default-servlet-handler/>
<mvc:resources mapping="/static/**" location="/static/"/>
<mvc:resources mapping="/css/**" location="/css/"/>
<mvc:resources mapping="/js/**" location="/js/"/>
<mvc:resources mapping="/images/**" location="/images/"/>
<bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
</bean>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="5242880"/>
<property name="defaultEncoding" value="UTF-8"/>
</bean>
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="defaultErrorView" value="error"/>
<property name="exceptionAttribute" value="exception"/>
</bean>
</beans>

@ -1,19 +0,0 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>商品信息</title>
</head>
<body>
<h3>Success!</h3>
<p>商品名称: ${product.productName}</p>
<p>是否热门: ${product.isHot}</p>
<p>市场价格: ${product.marketPrice}</p>
<p>销售价格: ${product.salePrice}</p>
<p>商品图片: ${product.productImage}</p>
<p>分类名称: ${product.categoryName}</p>
<p>商品描述: ${product.productDesc}</p>
<p>上架日期: ${product.shelfDate}</p>
</body>
</html>

@ -1,45 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>hospital-SpringMVCProject</display-name>
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<display-name>hospital</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>admin</welcome-file>
</welcome-file-list>
<!-- 1.Spring配置文件让Spring在web项目中起作用让Spring IoC容器跟随项目一起启动 -->
<!-- needed for ContextLoaderListener -->
<context-param>
<param-name>contextConfigLocation</param-name>
<!-- 指定Spring配置文件的地址 -->
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- Bootstraps the root web application context before servlet initialization -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 2.SpringMVC配置文件前端控制器 -->
<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
<servlet>
<servlet-name>springDispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- SpringMVC要想启动得需要他的配置文件 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map all requests to the DispatcherServlet for handling -->
<servlet-mapping>
<servlet-name>springDispatcherServlet</servlet-name>
<url-pattern>/</url-pattern><!-- 拦截所有请求 -->
</servlet-mapping>
<!-- 解决中文乱码问题 -->
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

@ -1,61 +0,0 @@
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加商品</title>
</head>
<body>
<form action="${pageContext.request.contextPath}/product/newadd" method="post">
<table>
<tr>
<td><label for="productId">商品编号:</label></td>
<td><input type="text" id="productId" name="productId" /></td>
</tr>
<tr>
<td><label for="productName">商品名称:</label></td>
<td><input type="text" id="productName" name="productName" /></td>
</tr>
<tr>
<td><label for="isHot">是否热门:</label></td>
<td>
<select id="isHot" name="isHot">
<option value="1">是</option>
<option value="0">否</option>
</select>
</td>
</tr>
<tr>
<td><label for="marketPrice">市场价格:</label></td>
<td><input type="text" id="marketPrice" name="marketPrice" /></td>
</tr>
<tr>
<td><label for="salePrice">销售价格:</label></td>
<td><input type="text" id="salePrice" name="salePrice" /></td>
</tr>
<tr>
<td><label for="productImage">商品图片:</label></td>
<td><input type="file" id="productImage" name="productImage" /></td>
</tr>
<tr>
<td><label for="categoryName">分类名称:</label></td>
<td><input type="text" id="categoryName" name="categoryName" /></td>
</tr>
<tr>
<td><label for="productDesc">商品描述:</label></td>
<td><textarea id="productDesc" name="productDesc" rows="5" cols="30"></textarea></td>
</tr>
<tr>
<td><label for="shelfDate">上架日期:</label></td>
<td><input type="text" id="shelfDate" name="shelfDate" /></td>
</tr>
<tr>
<td colspan="2" style="text-align: center;">
<input type="reset" value="重置" />
<input type="submit" value="添加" />
</td>
</tr>
</table>
</form>
</body>
</html>

@ -3,6 +3,29 @@
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<!-- mybatis全局配置文件 -->
<configuration>
</configuration>
<configuration>
<!-- 配置实体类别名 -->
<typeAliases>
<package name="com.ssm.entity"/>
</typeAliases>
<!-- 配置环境 -->
<environments default="development">
<environment id="development">
<!-- 配置事务 -->
<transactionManager type="JDBC"/>
<!-- 配置数据源 -->
<dataSource type="POOLED">
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/ssm_hospital1?useUnicode=true&amp;characterEncoding=utf8&amp;serverTimezone=Asia/Shanghai&amp;useSSL=false&amp;allowPublicKeyRetrieval=true"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</dataSource>
</environment>
</environments>
<!-- 配置mapper映射文件 -->
<mappers>
<package name="com.ssm.mapper"/>
</mappers>
</configuration>

@ -2,84 +2,70 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
xsi:schemaLocation="http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<!-- 1.自动扫描包希望Spring管理所有业务逻辑组件、Bean等,SpringMVC负责网站跳转逻辑的控制Controller
注意①当springmvc.xml配置了只扫描@Controller此处就要配
除了标了@Controller注解的控制器以外都扫描即配置子标签
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> -->
<!-- 1.自动扫描包使用注解方式管理Bean -->
<!-- 扫描@Service、@Repository、@Component等注解 -->
<context:component-scan base-package="com.ssm">
<!-- 排除@Controller注解由SpringMVC管理 -->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- 2.引入db.properties
注意:①方式二:<bean id="" class="PropertyPlaceholderConfigurer"> -->
<context:property-placeholder location="classpath:db.properties"/>
<!-- 2.启用注解驱动 -->
<!-- 支持@Autowired、@Value等注解 -->
<context:annotation-config/>
<!-- 3.引入数据库的数据源配置:
注意①还可以配置事务控制、AOP等
②当使用c3p0连接池时配置如下
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${driver}"></property>
<property name="jdbcUrl" value="${url}"></property>
<property name="user" value="${user}"></property>
<property name="password" value="${password}"></property>
</bean> -->
<!-- 3.以下AOP和事务配置暂时注释,需要时再启用 -->
<!-- ============================================ -->
<!-- 以下配置暂时注释,需要数据库时再启用 -->
<!-- ============================================ -->
<!-- 4.引入db.properties配置文件 -->
<!-- <context:property-placeholder location="classpath:db.properties"/> -->
<!-- 5.配置数据源 -->
<!--
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
<!-- 这里报错说明类中不存在这个属性,需要改成规定的属性名 -->
<property name="driverClassName" value="${driver}"></property>
<property name="url" value="${url}"></property>
<property name="username" value="${user}"></property>
<property name="password" value="${password}"></property>
<property name="driverClassName" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${user}"/>
<property name="password" value="${password}"/>
<property name="initialSize" value="5"/>
<property name="maxTotal" value="20"/>
<property name="maxIdle" value="10"/>
<property name="minIdle" value="5"/>
</bean>
-->
<!-- 事务管理器DataSourceTransactionManager该类在spring-jdbc包中指定这个事务管理器管理配置的dataSource数据源 -->
<!-- <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean> -->
<!-- 开启基于注解的事务 -->
<!-- <tx:annotation-driven transaction-manager="dataSourceTransactionManager"/> -->
<!-- 6.配置MyBatis的SqlSessionFactory -->
<!--
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations" value="classpath:com/ssm/mapper/*.xml"/>
<property name="typeAliasesPackage" value="com.ssm.entity"/>
</bean>
-->
<!-- 4.整合mybatis配置:创建MyBatis核心对象SqlSessionFactory整合关键步骤
目的:(1)想让Spring管理所有组件包括mapper
以后Service层要调用Dao层时只需使用@Autowired注解自动注入即可。
这样就避免了每次操作增删改查之前需要先获取到SqlSessionFactory->SqlSession->getMapper方法获得动态代理对象
即接口类的对象,然后才能操作具体增删改查操作。
(2)Spring声明式事务非常强大想让Spring管理事务。
注意①SqlSessionFactoryBean类能创建出SqlSessionFactory对象意味着容器一启动让容器帮我们创建SqlSessionFactory-->
<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 访问数据库必然需要数据源,管理数据库的连接,提高数据库性能,在数据源中配置使用的连接池 -->
<property name="dataSource" ref="dataSource"></property>
<!-- 加载MyBatis全局配置文件config.xml如果config.xml中没有东西可以删掉
但一般建议留下可以放一些不太常用的配置如全局参数settings、数据库提供厂商等配置 -->
<!-- <property name="configLocation" value="classpath:config.xml"></property> -->
<!-- 指定SQL映射文件的位置当SQL映射文件和接口名不一致时使用该方法指定。
(不讲)?如果名字一致,则可以使用<mybatis:scan base-package=""/>扫描所有mapper SQL映射文件(报错mybatis前缀未绑定)? -->
<property name="mapperLocations" value="classpath:com/ssm/mapper/*.xml"></property>
<!-- 此处还可以配置别名处理器等,这些以前都是在全局配置文件中定义的现在都变成sqlSessionFactoryBean的一个属性,
相当于mybatis全局配置文件中的内容都拿到Spring配置文件来配置。 -->
<!-- 7.扫描Mapper接口自动生成代理对象 -->
<!-- 需要在Mapper接口上添加@Mapper注解或使用@MapperScan -->
<!--
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.ssm.mapper"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
-->
<!-- 5.扫描所有的mapper接口类让这些mapper能够自动注入
base-package:指定mapper接口的包名
注意:① 查找类路径下的映射器并自动将它们创建成MapperFactoryBean
即扫描所有的mapper接口类让这些mapper能够自动注入
② 如果有红叉报错也可以用,是约束引入有问题,不影响;
③ 以前还有这种写法(老版的项目一般这么做):
a.使用MapperScannerConfigurer
<bean class="MapperScannerConfigurer">
<property name="basePackage" value="Dao接口包名"/>
<bean> 或者
b.采用实体DAO调用方式采用接口org.apache.ibatis.session.SqlSession的实现类org.mybatis.spring.SqlSessionTemplate
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory"></constructor-arg>
</bean>
<!-- 8.配置事务管理器 -->
<!--
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
-->
<mybatis-spring:scan base-package="com.ssm.mapper"/>
<!-- 9.启用注解式事务 -->
<!-- 在Service方法上使用@Transactional注解 -->
<!-- <tx:annotation-driven transaction-manager="transactionManager"/> -->
</beans>

@ -4,7 +4,6 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 配置Patient实体类的Bean -->
<bean id="patient" class="com.ssm.ioc.Patient">
<property name="patientId" value="1001"/>
<property name="patientName" value="张三"/>
@ -14,7 +13,6 @@
<property name="address" value="北京市朝阳区建国路100号"/>
</bean>
<!-- 配置Doctor实体类的Bean -->
<bean id="doctor" class="com.ssm.ioc.Doctor">
<property name="doctorId" value="2001"/>
<property name="doctorName" value="李医生"/>
@ -24,7 +22,6 @@
<property name="email" value="li.doctor@hospital.com"/>
</bean>
<!-- 配置Department实体类的Bean -->
<bean id="department" class="com.ssm.ioc.Department">
<property name="deptId" value="3001"/>
<property name="deptName" value="内科"/>
@ -34,7 +31,6 @@
<property name="description" value="内科是医院的核心科室,负责常见疾病的诊断和治疗"/>
</bean>
<!-- 配置Appointment实体类的Bean -->
<bean id="appointment" class="com.ssm.ioc.Appointment">
<property name="appointmentId" value="4001"/>
<property name="patientName" value="张三"/>
@ -44,4 +40,77 @@
<property name="status" value="已预约"/>
</bean>
</beans>
<bean id="medicine" class="com.ssm.ioc.Medicine">
<property name="medicineId" value="5001"/>
<property name="medicineName" value="阿莫西林"/>
<property name="specification" value="0.5g*20粒"/>
<property name="manufacturer" value="华北制药"/>
<property name="price" value="25.5"/>
<property name="type" value="抗生素"/>
<property name="description" value="用于治疗细菌感染"/>
</bean>
<bean id="registration" class="com.ssm.ioc.Registration">
<property name="registrationId" value="6001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="doctorName" value="李医生"/>
<property name="doctorId" value="2001"/>
<property name="department" value="内科"/>
<property name="registrationDate" value="2026-04-14"/>
<property name="status" value="已挂号"/>
</bean>
<bean id="medicalRecord" class="com.ssm.ioc.MedicalRecord">
<property name="recordId" value="7001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="doctorName" value="李医生"/>
<property name="doctorId" value="2001"/>
<property name="diagnosis" value="上呼吸道感染"/>
<property name="symptoms" value="发热、咳嗽、咽痛"/>
<property name="treatment" value="口服阿莫西林每日三次每次2粒"/>
<property name="recordDate" value="2026-04-14"/>
</bean>
<bean id="medicalOrder" class="com.ssm.ioc.MedicalOrder">
<property name="orderId" value="8001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="doctorName" value="李医生"/>
<property name="doctorId" value="2001"/>
<property name="medicineName" value="阿莫西林"/>
<property name="medicineId" value="5001"/>
<property name="dosage" value="0.5g"/>
<property name="frequency" value="每日三次"/>
<property name="usage" value="口服"/>
<property name="orderDate" value="2026-04-14"/>
<property name="status" value="已执行"/>
</bean>
<bean id="hospitalization" class="com.ssm.ioc.Hospitalization">
<property name="hospitalizationId" value="9001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="orderId" value="8001"/>
<property name="department" value="内科"/>
<property name="roomNo" value="301"/>
<property name="bedNo" value="01"/>
<property name="admitDate" value="2026-04-14"/>
<property name="dischargeDate" value="2026-04-20"/>
<property name="status" value="住院中"/>
</bean>
<bean id="expense" class="com.ssm.ioc.Expense">
<property name="expenseId" value="10001"/>
<property name="orderId" value="8001"/>
<property name="patientName" value="张三"/>
<property name="patientId" value="1001"/>
<property name="expenseType" value="药品费"/>
<property name="amount" value="25.5"/>
<property name="description" value="阿莫西林药费"/>
<property name="expenseDate" value="2026-04-14"/>
<property name="status" value="已结算"/>
</bean>
</beans>

@ -1,4 +1,4 @@
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/ssm_farm?serverTimezone=Asia/Shanghai
url=jdbc:mysql://localhost:3306/ssm_farm?useSSL=false&serverTimezone=Asia/Shanghai
user=root
password=root

@ -9,33 +9,43 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd">
<!-- 配置扫描器
只扫描标了@Controller的控制器
use-default-filters="false"禁用掉默认的过滤行为,只包含才会生效。即:
<context:component-scan base-package="com.ssm" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan> -->
<!-- <context:component-scan base-package="com.ssm"></context:component-scan> -->
<context:component-scan base-package="com.ssm" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- 视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"></property> <!-- 前缀 -->
<property name="suffix" value=".jsp"></property> <!-- 后缀 -->
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
<property name="contentType" value="text/html;charset=UTF-8"></property>
</bean>
<!-- 处理动态资源是SpringMVC的基础配置可以协调很多功能一般写SpringMVC项目都加上 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 正确的处理静态资源 -->
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value="text/html;charset=UTF-8"/>
</bean>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
</mvc:message-converters>
</mvc:annotation-driven>
<mvc:default-servlet-handler/>
<bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<mvc:resources mapping="/static/**" location="/static/"/>
<mvc:resources mapping="/css/**" location="/css/"/>
<mvc:resources mapping="/js/**" location="/js/"/>
<mvc:resources mapping="/images/**" location="/images/"/>
<bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
</bean>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize">
<value>5242880</value>
</property>
<property name="maxUploadSize" value="5242880"/>
<property name="defaultEncoding" value="UTF-8"/>
</bean>
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="defaultErrorView" value="error"/>
<property name="exceptionAttribute" value="exception"/>
</bean>
</beans>
</beans>
Loading…
Cancel
Save