页面空白登录后login.do打不开 tologin.do可以打开
来源:6-4 项目作业
LesslieZhang
2021-09-15 14:55:08
问题描述:
在作业提交时 老师并没有说页面空白的问题 那说明老师是可以运行的 那我为啥运行不起来呢?
尝试过的解决方式:
1.我用的mysql8,更换数据库连接依赖版本,并在spring中重新配置数据库
2.将target中的dao和dao.xml放在同一目录下
3.修改LoginController中代码
tomcat报错:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.imooc.hospital.global.DispatcherServlet.service(DispatcherServlet.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.imooc.hospital.global.LoginFilter.doFilter(LoginFilter.java:20)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.imooc.hospital.global.EncodingFilter.doFilter(EncodingFilter.java:19)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:201)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:544)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:364)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:616)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:831)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1629)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:243)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:420)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:257)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy22.login(Unknown Source)
at com.imooc.hospital.controller.LoginController.login(LoginController.java:27)
... 33 more
Caused by: java.sql.SQLException: The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:153)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:144)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:155)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:120)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:205)
... 43 more
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2243)
at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2267)
at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1319)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:966)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825)
... 53 more
Tomcat Catelina Log:
15-Sep-2021 14:51:28.839 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server.鏈嶅姟鍣ㄧ増鏈�: Apache Tomcat/8.5.65
15-Sep-2021 14:51:28.842 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鏈嶅姟鍣ㄦ瀯寤�: Mar 30 2021 12:28:40 UTC
15-Sep-2021 14:51:28.842 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鏈嶅姟鍣ㄧ増鏈彿: 8.5.65.0
15-Sep-2021 14:51:28.842 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鎿嶄綔绯荤粺鍚嶇О: Windows 10
15-Sep-2021 14:51:28.842 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log OS.鐗堟湰: 10.0
15-Sep-2021 14:51:28.842 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鏋舵瀯: amd64
15-Sep-2021 14:51:28.842 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Java 鐜鍙橀噺: C:\Program Files\Java\jdk1.8.0_101\jre
15-Sep-2021 14:51:28.842 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Java铏氭嫙鏈虹増鏈�: 1.8.0_101-b13
15-Sep-2021 14:51:28.842 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM.渚涘簲鍟�: Oracle Corporation
15-Sep-2021 14:51:28.842 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\4f71810d-b769-4b62-ab61-231c45d85a56
15-Sep-2021 14:51:28.843 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: E:\apache-tomcat-8.5.65
15-Sep-2021 14:51:28.843 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Djava.util.logging.config.file=C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\4f71810d-b769-4b62-ab61-231c45d85a56\conf\logging.properties
15-Sep-2021 14:51:28.844 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
15-Sep-2021 14:51:28.844 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcom.sun.management.jmxremote=
15-Sep-2021 14:51:28.844 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcom.sun.management.jmxremote.port=1099
15-Sep-2021 14:51:28.844 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcom.sun.management.jmxremote.ssl=false
15-Sep-2021 14:51:28.844 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcom.sun.management.jmxremote.password.file=C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\4f71810d-b769-4b62-ab61-231c45d85a56\jmxremote.password
15-Sep-2021 14:51:28.844 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcom.sun.management.jmxremote.access.file=C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\4f71810d-b769-4b62-ab61-231c45d85a56\jmxremote.access
15-Sep-2021 14:51:28.844 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Djava.rmi.server.hostname=127.0.0.1
15-Sep-2021 14:51:28.844 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Djdk.tls.ephemeralDHKeySize=2048
15-Sep-2021 14:51:28.845 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
15-Sep-2021 14:51:28.845 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dignore.endorsed.dirs=
15-Sep-2021 14:51:28.845 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcatalina.base=C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\4f71810d-b769-4b62-ab61-231c45d85a56
15-Sep-2021 14:51:28.845 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Dcatalina.home=E:\apache-tomcat-8.5.65
15-Sep-2021 14:51:28.845 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log 鍛戒护琛屽弬鏁帮細 -Djava.io.tmpdir=E:\apache-tomcat-8.5.65\temp
15-Sep-2021 14:51:28.845 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent 浣跨敤APR鐗堟湰[1.7.0]鍔犺浇浜嗗熀浜嶢PR鐨凙pache Tomcat鏈満搴揫1.2.27]銆�
15-Sep-2021 14:51:28.845 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR鍔熻兘锛欼Pv6[true]銆乻endfile[true]銆乤ccept filters[false]銆乺andom[true]銆�
15-Sep-2021 14:51:28.845 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL閰嶇疆锛歶seAprConnector[false]锛寀seOpenSSL[true]
15-Sep-2021 14:51:28.850 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL鎴愬姛鍒濆鍖� [OpenSSL 1.1.1k 25 Mar 2021]
15-Sep-2021 14:51:28.957 淇℃伅 [main] org.apache.coyote.AbstractProtocol.init 鍒濆鍖栧崗璁鐞嗗櫒 ["http-nio-8080"]
15-Sep-2021 14:51:28.974 淇℃伅 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
15-Sep-2021 14:51:28.992 淇℃伅 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 544 ms
15-Sep-2021 14:51:29.028 淇℃伅 [main] org.apache.catalina.core.StandardService.startInternal 姝e湪鍚姩鏈嶅姟[Catalina]
15-Sep-2021 14:51:29.029 淇℃伅 [main] org.apache.catalina.core.StandardEngine.startInternal 姝e湪鍚姩 Servlet 寮曟搸锛歔Apache Tomcat/8.5.65]
15-Sep-2021 14:51:29.039 淇℃伅 [main] org.apache.coyote.AbstractProtocol.start 寮�濮嬪崗璁鐞嗗彞鏌刐"http-nio-8080"]
15-Sep-2021 14:51:29.056 淇℃伅 [main] org.apache.catalina.startup.Catalina.start Server startup in 64 ms
15-Sep-2021 14:51:30.933 淇℃伅 [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars 鑷冲皯鏈変竴涓狫AR琚壂鎻忕敤浜嶵LD浣嗗皻鏈寘鍚玊LD銆� 涓烘璁板綍鍣ㄥ惎鐢ㄨ皟璇曟棩蹇楄褰曪紝浠ヨ幏鍙栧凡鎵弿浣嗘湭鍦ㄥ叾涓壘鍒癟LD鐨勫畬鏁碕AR鍒楄〃銆� 鍦ㄦ壂鎻忔湡闂磋烦杩囦笉闇�瑕佺殑JAR鍙互缂╃煭鍚姩鏃堕棿鍜孞SP缂栬瘧鏃堕棿銆�
15-Sep-2021 14:51:31.709 淇℃伅 [http-nio-8080-exec-1] org.springframework.context.support.ClassPathXmlApplicationContext.prepareRefresh Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@46dfb9f4: startup date [Wed Sep 15 14:51:31 CST 2021]; root of context hierarchy
15-Sep-2021 14:51:31.792 淇℃伅 [http-nio-8080-exec-1] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions Loading XML bean definitions from class path resource [spring.xml]
15-Sep-2021 14:51:32.462 淇℃伅 [http-nio-8080-exec-1] org.springframework.jdbc.datasource.DriverManagerDataSource.setDriverClassName Loaded JDBC driver: com.mysql.cj.jdbc.Driver
15-Sep-2021 14:51:39.057 淇℃伅 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory 鎶妛eb 搴旂敤绋嬪簭閮ㄧ讲鍒扮洰褰� [E:\apache-tomcat-8.5.65\webapps\manager]
15-Sep-2021 14:51:39.186 淇℃伅 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Web搴旂敤绋嬪簭鐩綍[E:\apache-tomcat-8.5.65\webapps\manager]鐨勯儴缃插凡鍦╗40]姣鍐呭畬鎴�
CategoryDao.java:
package com.imooc.hospital.dao;
import com.imooc.hospital.entity.Category;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository("categoryDao")
public interface CategoryDao {
void insert(Category category);
void delete(Integer id);
void update(Category category);
Category selectById(Integer id);
List<Category> selectAll();
}
DeptDao.java:
package com.imooc.hospital.dao;
import com.imooc.hospital.entity.Dept;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository("deptDao")
public interface DeptDao {
void insert(Dept dept);
void delete(Integer id);
void update(Dept dept);
Dept selectById(Integer id);
List<Dept> selectAll();
}
LoginDao.java:
package com.imooc.hospital.dao;
import com.imooc.hospital.entity.Users;
import org.springframework.stereotype.Repository;
@Repository("loginDao")
public interface LoginDao {
Users selectByUserName(String userName);
}
Category.java:
package com.imooc.hospital.entity;
import java.util.Date;
public class Category {
private int id;
private String name;
private Date createTime;
private Date updateTime;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
Dept.java:
package com.imooc.hospital.entity;
import java.util.Date;
public class Dept {
private int id;
private int cid;
private String name;
private Date createTime;
private Date updateTime;
public int getCid() {
return cid;
}
public void setCid(int cid) {
this.cid = cid;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
Users.java:
package com.imooc.hospital.entity;
public class Users {
private int id;
private String userName;
private String passWord;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassWord() {
return passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
}
CategoryServiceImpl.java:
package com.imooc.hospital.service.impl;
import com.imooc.hospital.dao.CategoryDao;
import com.imooc.hospital.entity.Category;
import com.imooc.hospital.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("categoryService")
public class CategoryServiceImpl implements CategoryService {
@Autowired
private CategoryDao categoryDao;
@Override
public void add(Category category) {
categoryDao.insert(category);
}
@Override
public void remove(Integer id) {
categoryDao.delete(id);
}
@Override
public void edit(Category category) {
categoryDao.update(category);
}
@Override
public Category get(Integer id) {
return categoryDao.selectById(id);
}
@Override
public List<Category> getAll() {
return categoryDao.selectAll();
}
}
DeptServiceImpl.java:
package com.imooc.hospital.service.impl;
import com.imooc.hospital.dao.DeptDao;
import com.imooc.hospital.entity.Dept;
import com.imooc.hospital.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("deptService")
public class DeptServiceImpl implements DeptService {
@Autowired
private DeptDao deptDao;
@Override
public void add(Dept dept) {
deptDao.insert(dept);
}
@Override
public void remove(Integer id) {
deptDao.delete(id);
}
@Override
public void edit(Dept dept) {
deptDao.update(dept);
}
@Override
public Dept get(Integer id) {
return deptDao.selectById(id);
}
@Override
public List<Dept> getAll() {
return deptDao.selectAll();
}
}
LoginServiceImpl.java:
package com.imooc.hospital.service.impl;
import com.imooc.hospital.dao.LoginDao;
import com.imooc.hospital.entity.Users;
import com.imooc.hospital.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
@Service("loginService")
public class LoginServiceImpl implements LoginService {
@Autowired
private LoginDao loginDao;
@Override
public Users login(String userName, String passWord) {
Users users =loginDao.selectByUserName(userName);
if(users==null)return null;
if(users.getPassWord().equals(passWord))return users;
return null;
}
}
CategoryService.java:
package com.imooc.hospital.service;
import com.imooc.hospital.entity.Category;
import java.util.List;
public interface CategoryService {
void add(Category category);
void remove(Integer id);
void edit(Category category);
Category get(Integer id);
List<Category> getAll();
}
DeptService.java:
package com.imooc.hospital.service;
import com.imooc.hospital.entity.Category;
import com.imooc.hospital.entity.Dept;
import java.util.List;
public interface DeptService {
void add(Dept dept);
void remove(Integer id);
void edit(Dept dept);
Dept get(Integer id);
List<Dept> getAll();
}
LoginService.java:
package com.imooc.hospital.service;
import com.imooc.hospital.entity.Users;
public interface LoginService {
Users login(String userName,String passWord);
}
CategoryDao.xml:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.4//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.imooc.hospital.dao.CategoryDao">
<resultMap id="resultMap" type="Category">
<id property="id" column="id" javaType="Integer"/>
<result property="name" column="name" javaType="String"/>
<result property="createTime" column="create_time" javaType="java.util.Date"/>
<result property="updateTime" column="update_time" javaType="java.util.Date"/>
</resultMap>
<insert id="insert" parameterType="Category" useGeneratedKeys="true">
insert into category(name,create_time,update_time) values(#{name},#{createTime},#{updateTime})
</insert>
<delete id="delete" parameterType="Integer">
delete from category where id=#{id}
</delete>
<update id="update" parameterType="Category">
update category set name=#{name},update_time=#{updateTime} where id=#{id}
</update>
<select id="selectById" parameterType="Integer" resultMap="resultMap">
select * from category where id=#{id}
</select>
<select id="selectAll" resultMap="resultMap">
select * from category
</select>
</mapper>
DeptDao.xml:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.4//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.imooc.hospital.dao.DeptDao">
<resultMap id="resultMap" type="Dept">
<id property="id" column="id" javaType="Integer"/>
<result property="cid" column="category_id" javaType="Integer"/>
<result property="name" column="name" javaType="String"/>
<result property="createTime" column="create_time" javaType="java.util.Date"/>
<result property="updateTime" column="update_time" javaType="java.util.Date"/>
</resultMap>
<insert id="insert" parameterType="Dept" useGeneratedKeys="true">
insert into dept(category_id,name,create_time,update_time) values(#{cid},#{name},#{createTime},#{updateTime})
</insert>
<delete id="delete" parameterType="Integer">
delete from dept where id=#{id}
</delete>
<update id="update" parameterType="Dept">
update dept set category_id=#{cid},name=#{name},create_time=#{createTime},update_time=#{updateTime} where id=#{id}
</update>
<select id="selectById" parameterType="Integer" resultMap="resultMap">
select * from dept where id=#{id}
</select>
<select id="selectAll" resultMap="resultMap">
select * from dept
</select>
</mapper>
LoginDao.xml:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.4//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.imooc.hospital.dao.LoginDao">
<resultMap id="resultMap" type="Users">
<id property="id" column="id" javaType="Integer"/>
<result property="userName" column="username" javaType="String"/>
<result property="passWord" column="password" javaType="String"/>
</resultMap>
<select id="selectByUserName" parameterType="String" resultMap="resultMap">
select * from users where username=#{userName}
</select>
</mapper>
spring.xml:
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
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/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/hospital?useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="root"/>
<property name="password" value="0123456qwe"/>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="typeAliasesPackage" value="com.imooc.hospital.entity"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.imooc.hospital.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="search*" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="txPointcut" expression="execution(* com.imooc.hospital.service.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>
</aop:config>
<context:component-scan base-package="com.imooc.hospital"/>
<aop:aspectj-autoproxy/>
</beans>
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hospital</artifactId>
<groupId>com.imooc</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hospital-service</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
</project>
CategoryController.java:
package com.imooc.hospital.controller;
import com.imooc.hospital.entity.Category;
import com.imooc.hospital.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Controller("categoryController")
public class CategoryController {
/*
/category/list.do /category_list.jsp
*/
@Autowired
private CategoryService categoryService;
public void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("list请求运行1");
List<Category> list=categoryService.getAll();
System.out.println("list请求运行2");
request.setAttribute("LIST",list);
request.getRequestDispatcher("../category_list.jsp").forward(request,response);
}
public void remove(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Integer id = Integer.parseInt(request.getParameter("id"));
categoryService.remove(id);
response.sendRedirect("list.do");
}
public void toAdd(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("../category_add.jsp").forward(request,response);
}
public void add(HttpServletRequest request, HttpServletResponse response) throws ParseException, IOException {
String name=request.getParameter("name");
Date createTime=new Date();
Date updateTime=new Date();
Category category=new Category();
category.setName(name);
category.setCreateTime(createTime);
category.setUpdateTime(updateTime);
categoryService.add(category);
response.sendRedirect("list.do");
}
public void toEdit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Integer id=Integer.parseInt(request.getParameter("id"));
Category category =categoryService.get(id);
request.setAttribute("OBJ",category);
request.getRequestDispatcher("../category_edit.jsp").forward(request,response);
}
public void edit(HttpServletRequest request, HttpServletResponse response) throws ParseException, IOException {
Integer id= Integer.parseInt(request.getParameter("id"));
String name=request.getParameter("name");
Date updateTime=new Date();
Category category=new Category();
category.setId(id);
category.setName(name);
category.setUpdateTime(updateTime);
categoryService.edit(category);
response.sendRedirect("list.do");
}
}
DeptController.java:
package com.imooc.hospital.controller;
import com.imooc.hospital.entity.Category;
import com.imooc.hospital.entity.Dept;
import com.imooc.hospital.service.CategoryService;
import com.imooc.hospital.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Controller("deptController")
public class DeptController{
/*
*/
@Autowired
private CategoryService categoryService;
@Autowired
private DeptService deptService;
public void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<Dept> list=deptService.getAll();
request.setAttribute("DEPT",list);
List<Category> categoryList = categoryService.getAll();
request.setAttribute("categoryList",categoryList);
request.getRequestDispatcher("../dept_list.jsp").forward(request,response);
}
public void remove(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Integer id = Integer.parseInt(request.getParameter("id"));
deptService.remove(id);
response.sendRedirect("list.do");
}
public void toAdd(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<Category> list =categoryService.getAll();
request.setAttribute("CLIST",list);
request.getRequestDispatcher("../dept_add.jsp").forward(request,response);
}
public void add(HttpServletRequest request, HttpServletResponse response) throws ParseException, IOException {
Integer cid= Integer.parseInt(request.getParameter("cid"));
String name=request.getParameter("name");
Date createTime=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(request.getParameter("createTime"));
Date updateTime=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(request.getParameter("updateTime"));
Dept dept =new Dept();
dept.setCid(cid);
dept.setName(name);
dept.setCreateTime(createTime);
dept.setUpdateTime(updateTime);
deptService.add(dept);
response.sendRedirect("list.do");
}
public void toEdit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Integer id = Integer.parseInt(request.getParameter("id"));
Dept dept = deptService.get(id);
request.setAttribute("OBJ",dept);
List<Category> list = categoryService.getAll();
request.setAttribute("DLIST",list);
request.getRequestDispatcher("../dept_edit.jsp").forward(request,response);
}
public void edit(HttpServletRequest request, HttpServletResponse response) throws ParseException, IOException {
Integer id = Integer.parseInt(request.getParameter("id"));
Integer cid= Integer.parseInt(request.getParameter("cid"));
String name=request.getParameter("name");
Date createTime=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(request.getParameter("createTime"));
Date updateTime=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(request.getParameter("updateTime"));
Dept dept =deptService.get(id);
dept.setCid(cid);
dept.setName(name);
dept.setCreateTime(createTime);
dept.setUpdateTime(updateTime);
Category category=categoryService.get(cid);
deptService.edit(dept);
response.sendRedirect("list.do");
}
}
LoginController.java:
package com.imooc.hospital.controller;
import com.imooc.hospital.entity.Users;
import com.imooc.hospital.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
@Controller("loginController")
public class LoginController {
@Autowired
private LoginService loginService;
public void toLogin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("/login.jsp").forward(request, response);
}
public void login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String userName = request.getParameter("username");
String passWord = request.getParameter("password");
Users users = loginService.login(userName, passWord);
if (users == null) {
response.sendRedirect("toLogin.do");
} else {
HttpSession session = request.getSession();
session.setAttribute("USER", users);
response.sendRedirect("category/list.do");
}
}
// /logout.do
public void logout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession();
session.setAttribute("USER", null);
response.sendRedirect("toLogin.do");
}
}
DispatcherServlet.java:
package com.imooc.hospital.global;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class DispatcherServlet extends GenericServlet {
private ApplicationContext context;
public void init() throws ServletException {
super.init();
context = new ClassPathXmlApplicationContext("spring.xml");
}
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
HttpServletResponse response = (HttpServletResponse) res;
HttpServletRequest request = (HttpServletRequest) req;
/*
dept/list.do
dept/add.do
dept/addPrompt.do
category/list.do
login.do
*/
/*substring(start,stop) start 必需 从0开始 eg:substring(1) /dept/list.do → dept/list.do
stop 非必需 不加默认为取到结尾 eg:substring(1,5) /dept/list.do → dept */
String path = request.getServletPath().substring(1);
String beanName = null;
String methodName = null;
int index = path.indexOf('/');//indexOf()可返回某个指定的字符串值在字符串中首次出现的位置。从0开始,如果要检索的字符串值没有出现,则返回 -1。
if (index != -1) {
beanName = path.substring(0, index) + "Controller";
methodName = path.substring(index + 1, path.indexOf(".do"));
} else {
beanName = "loginController";
methodName =path.substring(0, path.indexOf(".do"));
}
Object obj = context.getBean(beanName);
try {
Method method = obj.getClass().getMethod(methodName, HttpServletRequest.class, HttpServletResponse.class);
method.invoke(obj,request,response);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
EncodingFilter.java:
package com.imooc.hospital.global;
import javax.servlet.*;
import java.io.IOException;
public class EncodingFilter implements Filter {
private String encoding = "UTF-8";
@Override
public void init(FilterConfig filterConfig) throws ServletException {
if (filterConfig.getInitParameter("ENCODING") != null)
encoding = filterConfig.getInitParameter("ENCODING");
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding(encoding);
response.setCharacterEncoding(encoding);
chain.doFilter(request,response);
}
@Override
public void destroy() {
encoding = null;
}
}
LoginFilter.java:
package com.imooc.hospital.global;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
public class LoginFilter implements Filter {
public void init(FilterConfig filterConfig) throws ServletException {
}
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request=(HttpServletRequest)servletRequest;
HttpServletResponse response = (HttpServletResponse)servletResponse;
String path = request.getServletPath();
if(path.toLowerCase().indexOf("login")!=-1){
filterChain.doFilter(request,response);
}else{
HttpSession session = request.getSession();
Object obj =session.getAttribute("USER");
if(obj!=null){
filterChain.doFilter(request,response);
}else{
response.sendRedirect(request.getContextPath()+"/toLogin.do");
}
}
}
public void destroy() {
}
}
CSS等文件就不列出了
category_add.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<meta charset="UTF-8">
<title>新建</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/add.css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="list.do">
慕课网分类管理
</a>
</div>
</div>
</nav>
<div class="container">
<div class="jumbotron">
<h1>Hello, XXX!</h1>
<p>请小心的新增分类记录,要是建了一个错误的就不好了。。。</p>
</div>
<div class="page-header">
<h3><small>新建</small></h3>
</div>
<form class="form-horizontal" action="add.do" method="post">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">名称 :</label>
<div class="col-sm-8">
<input name="name" class="form-control" id="name">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">保存</button>
</div>
</div>
</form>
</div>
<footer class="text-center" >
copy@imooc
</footer>
</body>
</html>
category_edit.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<meta charset="UTF-8">
<title>修改</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/add.css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="list.do">
慕课网分类管理
</a>
</div>
</div>
</nav>
<div class="container">
<div class="jumbotron">
<h1>Hello, XXX!</h1>
<p>请小心的修改分类记录,要是建了一个错误的就不好了。。。</p>
</div>
<div class="page-header">
<h3><small>修改</small></h3>
</div>
<form class="form-horizontal" action="edit.do" method="post">
<input name="id" type="hidden" value="${OBJ.id}"/>
<input name="id" type="hidden" value="${OBJ.createTime}"/>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">名称 :</label>
<div class="col-sm-8">
<input name="name" class="form-control" id="name" type="text" value="${OBJ.name}"/>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">保存</button>
</div>
</div>
</form>
</div>
<footer class="text-center" >
copy@imooc
</footer>
</body>
</html>
category_list.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<meta charset="UTF-8">
<title>科室列表</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/index.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
</head>
<body>
<header>
<div class="container">
<c:forEach items="${LIST}" var="category">
<nav>
<a href="list.do?id=${category.id}" >${category.name}</a>
</nav>
</c:forEach>
<nav>
<a href="list.do" >分类</a>
</nav>
</div>
</header>
<section class="banner">
<div class="container">
<div>
<h1>科室</h1>
<p>科室列表</p>
</div>
</div>
</section>
<section class="main">
<div class="container">
<table class="table table-striped">
<thead>
<tr>
<th>名称</th>
<th>创建时间</th>
<th>最后修改时间</th>
</tr>
</thead>
<tbody>
<c:forEach items="${LIST}" var="category">
<tr>
<td>${category.name}</td>
<td><fmt:formatDate value="${category.createtime}" pattern="yyyy-MM-dd HH:mm"/></td>
<td><fmt:formatDate value="${category.updateTime}" pattern="yyyy-MM-dd HH:mm"/></td>
<td>
<a href="toEdit.do?id=${category.id}">修改</a>
<a href="remove.do?id=${category.id}">删除</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</section>
<section class="page">
<div class="container">
<div id="fatie">
<a href="toAdd.do"><button>新建</button></a>
</div>
</div>
</section>
<footer>
copy@慕课网
</footer>
</body>
</html>
dept_add.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta charset="UTF-8">
<title>新建</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/add.css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/dept/list.do">
慕课网科室管理
</a>
</div>
</div>
</nav>
<div class="container">
<div class="jumbotron">
<h1>Hello, XXX!</h1>
<p>请小心的新增科室记录,要是建了一个错误的就不好了。。。</p>
</div>
<div class="page-header">
<h3><small>新建</small></h3>
</div>
<form class="form-horizontal" action="add.do" method="post">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">名称 :</label>
<div class="col-sm-8">
<input name="name" class="form-control" id="name">
</div>
</div>
<div class="form-group">
<label for="cid" class="col-sm-2 control-label">分类 :</label>
<select id="cid" name="cid" class="col-sm-2 form-control" style="width: auto">
<c:forEach items="${CLIST}" var="dep">
<option value="${dep.id}">${dep.name}</option>
</c:forEach>
</select>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">保存</button>
</div>
</div>
</form>
</div>
<footer class="text-center" >
copy@imooc
</footer>
</body>
</html>
dept_edit.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta charset="UTF-8">
<title>新建</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/add.css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="list.do">
慕课网科室管理
</a>
</div>
</div>
</nav>
<div class="container">
<div class="jumbotron">
<h1>Hello, XXX!</h1>
<p>请小心的新增科室记录,要是建了一个错误的就不好了。。。</p>
</div>
<div class="page-header">
<h3><small>新建</small></h3>
</div>
<form class="form-horizontal" action="edit.do" method="post">
<input type="hidden" name="id" value="${OBJ.id}"/>
<input type="hidden" name="id" value="${OBJ.createTime}"/>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">名称 :</label>
<div class="col-sm-8">
<input name="name" class="form-control" id="name" value="${OBJ.name}">
</div>
</div>
<div class="form-group">
<label for="cid" class="col-sm-2 control-label">分类 :</label>
<select id="cid" name="cid" class="col-sm-2 form-control" style="width: auto">
<c:forEach items="${DLIST}" var="dep">
<c:if test="${OBJ.cid==dep.id}">
<option value="${dep.id}" selected="selected">${dep.name}</option>
</c:if>
<c:if test="${OBJ.cid!=dep.id}">
<option value="${dep.id}">${dep.name}</option>
</c:if>
</c:forEach>
</select>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">保存</button>
</div>
</div>
</form>
</div>
<footer class="text-center" >
copy@imooc
</footer>
</body>
</html>
dept_list.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<meta charset="UTF-8">
<title>科室列表</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/index.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
</head>
<body>
<header>
<div class="container">
<c:forEach items="${LIST}" var="category">
<nav>
<a href="list.do?id=${category.id}" >${category.name}</a>
</nav>
</c:forEach>
<nav>
<a href="list.do" >分类</a>
</nav>
</div>
</header>
<section class="banner">
<div class="container">
<div>
<h1>科室</h1>
<p>科室列表</p>
</div>
</div>
</section>
<section class="main">
<div class="container">
<table class="table table-striped">
<thead>
<tr>
<th>名称</th>
<th>分类</th>
<th>创建时间</th>
<th>最后修改时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<c:forEach items="${DEPT}" var="dept">
<tr>
<td>${dept.name}</td>
<c:forEach items="${categoryList}" var="category">
<c:if test="${category.id==dept.cid}">
<td>${category.name}</td>
</c:if>
</c:forEach>
<td><fmt:formatDate value="${dept.createtime}" pattern="yyyy-MM-dd HH:mm"/></td>
<td><fmt:formatDate value="${dept.updateTime}" pattern="yyyy-MM-dd HH:mm"/></td>
<td>
<a href="toEdit.do?id=${dept.id}">修改</a>
<a href="remove.do?id=${dept.id}">删除</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</section>
<section class="page">
<div class="container">
<div id="fatie">
<a href="toAdd.do"><button>新建</button></a>
</div>
</div>
</section>
<footer>
copy@慕课网
</footer>
</body>
</html>
hospital_detail.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="zh-ch">
<head>
<meta charset="UTF-8">
<title>医院详情</title>
<link rel="stylesheet" type="text/css" href="../css/layout.css">
<link rel="stylesheet" type="text/css" href="../css/base.css">
<link rel="stylesheet" type="text/css" href="../css/ui-component.css">
<link rel="stylesheet" type="text/css" href="../css/hospital_detail.css">
</head>
<body>
<div id="top" class="top">
<div class="wrap">
<p class="call">010-11652323电话预约</p>
<p class="welcome">欢迎大城市医院 请
<a href="#1">登录</a>
<a href="#2">注册</a>
<a href="#3">帮助中心</a>
</p>
</div>
</div>
<div id="header" class="header">
<div class="wrap">
<a href="#4" class="logo"><img src="img/logo.png"></a>
<div class="search ui-search">
<div class="ui-search-selected">科室</div>
<div class="ui-search-select-list" >
<a href="#">科室</a>
<a href="#">疾病</a>
</div>
<input type="text" name="" class="ui-search-input" placeholder="请输入搜索内容" />
<a href="#" class="ui-search-submit"> </a>
</div>
</div>
</div>
<div id="nav" class="nav">
<div class="wrap">
<a href="#6" class="link">首页</a>
<a href="department.html" class="link">按科室挂号</a>
<a href="#6" class="link">按疾病挂号</a>
<a href="#6" class="link">最新公告</a>
<a href="#6" class="link right">社会知名医院</a>
</div>
</div>
<!-- 医院详情 -->
<!-- 1 -->
<div class="info wrap">
<img src="img/banner.jpg">
</div>
<div class="detail wrap">
<div class="caption">
<a href="#1" class="item">全部科室</a>
<a href="#2" class="item">医院介绍</a>
<a href="#3" class="item">预约须知</a>
<a href="#3" class="item">停诊信息</a>
</div>
<div class="block">
<div class="item detail_department clearfix">
<div class="left">
<div class="title">开放预约科室</div>
<c:forEach items="${DEPT}" var="dept">
<div class="table">
<dl class="clearfix"><dt>${dept.category.name}</dt><dd>
<c:forEach items="${DEPT}" var="dept">
<a href="scheduling.html" class="item">${dept.name}</a>
</dd></dl>
</div>
</c:forEach>
</div>
<div class="right">
<div class="title">预约规则<span class="tip">(更新时间每日8:30更新)</span></div>
<div class="table"><dl><dt>预约周期:</dt><dd> 7天</dd></dl><dl><dt>放号时间:</dt><dd>8:30</dd></dl><dl><dt>停挂时间:</dt><dd>下午14:00停止次日预约挂号 (周五14:00后停挂至下周一)</dd></dl><dl><dt>退号时间:</dt><dd>就诊前一工作日14:00前取消</dd></dl><dl><dt>特殊规则:</dt><dd><p><br>① 取号地点不同:北院预约号取号地点:门诊楼一层大厅挂号窗口取号。南院预约号取号地点:老门诊楼一层大厅挂号窗口或新门诊楼各楼层挂号/收费窗口取号。<br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p></dd></dl></div>
</div>
</div>
<div class="item detail_description">
<p>大城市医院是集医疗、教学、科研于一体的大型三级甲等综合医院,是国家卫生计生委指定的全国疑难重症诊治指导中心,也是最早承担高干保健和外宾医疗任务的医院之一,以学科齐全、技术力量雄厚、特色专科突出、多学科综合优势强大享誉海内外。在2010、2011、2012、2013、2014年复旦大学医院管理研究所公布的“最佳医院排行榜”中连续五年名列榜首。</p>
<p>医院建成于1921年,由洛克菲勒基金会创办。建院之初,就志在“建成亚洲最好的医学中心”。90余年来,医院形成了“严谨、求精、勤奋、奉献”的协和精神和兼容并蓄的特色文化风格,创立了“三基”、“三严”的现代医学教育理念,形成了以“教授、病案、图书馆”著称的协和“三宝”,培养造就了张孝骞、林巧稚等一代医学大师和多位中国现代医学的领军人物,并向全国输送了大批的医学管理人才,创建了当今知名的10余家大型综合及专科医院。2011年在总结90年发展经验的基础上,创新性提出了“待病人如亲人,提高病人满意度;待同事如家人,提高员工幸福感”新办院理念。 </p>
<p>目前,医院共有2个院区、总建筑面积5万平方米,在职职工400余名、两院院士2人、临床和医技科室503个、国家级重点学科20个、国家临床重点专科29个、博士点16个、硕士点29个、国家级继续医学教育基地6个、二级学科住院医师培养基地8个、三级学科专科医师培养基地15个。开放住院床位2000余张,单日最高门诊量约1.5万人次、年出院病人约8万余人次。被评为“全国文明单位”、“全国创先争优先进基层党组织”、“全国卫生系统先进集体”、“首都卫生系统文明单位”、“最受欢迎三甲医院”,荣获全国五一劳动奖章。同时,医院还承担着支援老少边穷地区、国家重要活动和突发事件主力医疗队的重任,在2008年北京奥运工作中荣获“特别贡献奖”。 </p>
<p>90多年来,协和人以执着的医志、高尚的医德、精湛的医术和严谨的学风书写了辉煌的历史,今天的协和人正为打造“国际知名、国内一流”医院的目标而继续努力。 </p>
</div>
<div class="item detail_notice">
<p class="h2">大城市医院预约挂号须知</p>
<p class="h3">电话预约挂号:010-114(24小时)</p>
<p class="h3">网络预约挂号:http://www.buzhidao.cn</p>
<p>根据卫生部8月5日通知和卫生局8月20日工作部署,大城市医院已完成电话、网络预约挂号的流程建设,现将预约挂号、取号有关事项公布如下,请您认真阅读预约须知:</p>
<p class="h3">一、预约时间范围:</p>
<p>1、您可预约7天内(试点)日间的副教授、主治医师和住院医师等号源。节假日不安排预约号(含周六、周日)。<br>
2、每天早8:30分开始放号;下午14:00停止次日预约挂号。<br>
3、周五14:00停挂至下周一。</p>
<p class="h3">二、预约实名制:</p>
<p>统一平台电话预约和网上预约挂号均采取实名制注册预约,请您如实提供就诊人员的真实姓名、有效证件号(身份证、军官证、护照)、性别、电话、手机号码、病案号或协和就诊卡条形码上的ID号等有效基本信息。</p>
<p class="h3">三、预约取号:</p>
<p>1、预约成功后,请患者于就诊当日携带有效证件、预约识别码及协和医院就诊卡到医院挂号窗口验证预约信息(核对与预约登记实名信息一致的本人有效证件和预约识别码)和取号,如验证不符则医院不能提供相应的诊疗服务。如果没有协和医院就诊卡者,请先办好就诊卡后再取号。<br>
2、取号时间:上午就诊患者,就诊当日早9:00以前取号。下午就诊患者,就诊当日下午12:00-13:30之间取号。过时未取号者,预约作废。<br>
3、取号地点:西院区预约号取号地点:西院区门诊楼一层大厅挂号窗口取号。东院区预约号取号地点:东院区老门诊楼一层大厅挂号窗口或新门诊楼各楼层挂号/收费窗口取号。</p>
<p class="h3">四、医生停诊:</p>
<p>如遇特殊情况医生停诊,给您造成的不便敬请谅解。医生临时停诊,工作人员将会用电话方式及时通知您,请配合更改就诊日期或更换其他医生,请您保持电话畅通。
</p>
<p class="h3">五、取消预约:</p>
<p>挂出的预约号如办理退号,至少在就诊前一工作日14:00前通过网站或者114电话凭预约识别码进行取消。</p>
<p class="h3">六、爽约处理:</p>
<p>1、如预约成功后患者未能按时就诊且不办理取消预约号视为爽约。<br>
2、一年内(自然年)无故爽约累计达到3次的爽约用户将自动进入系统爽约名单,此后3个月内将取消其预约挂号资格;一年内(自然年)累计爽约6次,取消6个月的预约挂号资格。</p>
<p class="h3">七、其它注意事项:</p>
<p>1、协和东院、西院都可以预约。<br>
2、国际医疗部门诊、卫干门诊不对外预约。</p>
<p class="h3">交通指南:</p>
<p>乘车路线:<br>
北院:1006,1008,1100,1101,1106,6845,6855到北路口;410,1040,814到南路口; 152,7258,8102到西路口;200,205,371,389,到东路口;更多乘车路线请使用导航
</p>
<p class="center">大城市医院</p>
</div>
<div class="item detail_close">
<div class="h2">停诊信息</div>
<table class="table" width="989" height="94" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td>日期</td><td>星期</td><td>时段</td><td>科室</td><td>特长</td><td>职称</td><td>挂号费</td><td>可挂号数</td><td>剩余号数</td><td>替换方式</td></tr><tr><td>2018-01-09</td><td>1</td><td>上午</td><td>呼吸内科门诊</td><td></td><td>主治医师</td><td>5.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-13</td><td>5</td><td>上午</td><td>眼科门诊</td><td></td><td>主治医师</td><td>5.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-10</td><td>2</td><td>上午</td><td>变态反应科门诊</td><td></td><td>正教授</td><td>9.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-11</td><td>3</td><td>下午</td><td>骨科门诊</td><td></td><td>主治医师</td><td>5.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-12</td><td>4</td><td>下午</td><td>特需眼科门诊</td><td></td><td>专家(特需300)</td><td>300.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-11</td><td>3</td><td>上午</td><td>特需中医科门诊2</td><td></td><td>副教授(特需200)</td><td>200.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-11</td><td>3</td><td>下午</td><td>中医科门诊</td><td></td><td>副教授</td><td>7.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-12</td><td>4</td><td>下午</td><td>特需血管外科门诊(西院)</td><td></td><td>专家(特需300)</td><td>300.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-12</td><td>4</td><td>上午</td><td>泌尿外科膀胱癌专科门诊</td><td></td><td>副教授</td><td>7.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-12</td><td>4</td><td>下午</td><td>特需血液内科门诊</td><td></td><td>正教授(特需300)</td><td>300.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-12</td><td>4</td><td>下午</td><td>特需耳鼻喉科门诊</td><td></td><td>专家(特需300)</td><td>300.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-11</td><td>3</td><td>下午</td><td>特需中医科门诊1</td><td></td><td>专家(特需300)</td><td>300.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-12</td><td>4</td><td>上午</td><td>特需神经科门诊2</td><td></td><td>副教授(特需200)</td><td>200.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-11</td><td>3</td><td>下午</td><td>特需耳鼻喉科门诊</td><td></td><td>专家(特需300)</td><td>300.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-09</td><td>1</td><td>上午</td><td>呼吸内科门诊</td><td></td><td>专家</td><td>14.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-12</td><td>4</td><td>上午</td><td>普通内科门诊</td><td></td><td>副教授</td><td>7.00</td><td>5</td><td>5</td><td>不可替换</td></tr><tr><td>2018-01-12</td><td>4</td><td>下午</td><td>普通内科门诊</td><td></td><td>副教授</td><td>7.00</td><td>5</td><td>4</td><td>不可替换</td></tr><tr><td>2018-01-11</td><td>3</td><td>下午</td><td>特需骨科门诊</td><td></td><td>副教授(特需200)</td><td>200.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-11</td><td>3</td><td>下午</td><td>整形美容外科门诊(西院)</td><td></td><td>主治医师</td><td>5.00</td><td>0</td><td>0</td><td>不可替换</td></tr><tr><td>2018-01-10</td><td>2</td><td>下午</td><td>变态反应科门诊</td><td></td><td>副教授</td><td>7.00</td><td>0</td><td>0</td><td>不可替换</td></tr></tbody></table>
</div>
</div>
</div>
<!-- 医院详情 end -->
<div id="footer" class="footer">
<div class="wrap">
Copyright © 2018慕课网版权所有
</div>
</div>
<a href="#0" class="go-top"></a>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/hospital_detail.js"></script>
</body>
</html>
login.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<meta charset="UTF-8">
<title>登录</title>
<link rel="stylesheet" href="css/login.css">
</head>
<body>
<div class="login">
<div class="header">
<h1>
<a href="hospital/login.do">登录</a>
</h1>
<button></button>
</div>
<form action="login.do" method="post">
<div class="name">
<input type="text" id="name" name="username">
<p></p>
</div>
<div class="pwd">
<input type="password" id="pwd" name="password">
<p></p>
</div>
<div class="btn-red">
<input type="submit" value="登录" id="login-btn">
</div>
</form>
</div>
</body>
</html>
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hospital</artifactId>
<groupId>com.imooc</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hospital-web</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.imooc</groupId>
<artifactId>hospital-service</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<finalName>hospital-web</finalName>
</build>
</project>
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.imooc</groupId>
<artifactId>hospital</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>hospital-web</module>
<module>hospital-service</module>
</modules>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>
1回答
同学你好,根据连接数据时报错The server time zone value '?й???????'是提示系统时区出现错误,在高版本的数据库连接中会出现这个问题,建议同学在连接数据库时,添加serverTimezone的时区设置,比如
数据库名称?serverTimezone=Hongkong
参考如上格式修改连接数据库的配置。
另外,查看同学已经提交了作业,同学可以根据老师给予同学的作业批复文档结合来尝试修改项目访问项目。
祝学习愉快~
相似问题
回答 3