Java-手动搭建SSH

项目搭建工具:eclipse

项目开发环境:①Windows10-64位 ②Tomcat 8.5 ③jdk1.8.0_91 ④MySql 8.0.11

jar包准备:这里不详说,自己准备不不冲突能跑起来就没啥问题。

(1)新建一个Dynamic Web Project,可命名为SSH_Template,直接点击finish按钮 (2)将选择的jar包导入到lib(/WebContent/WEB-INF/lib)中,其中包括hibernate、mysql-connector-java、spring、struts2 (3)将导入的jar包添加到项目Libraries中,项目右键==》Properties==》Java Build Path==》Libraries==》选中导入的所有jar包添加到进Libraries中 (4)在/WebContent/WEB-INF/下新建一个web.xml,配置过滤器和监听器

web.xml

Java-手动搭建SSH

Java-手动搭建SSH

<?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 " id="WebApp_ID" version="3.1"> <display-name>ssh</display-name> <welcome-file-list> <welcome-file>index.action</welcome-file> </welcome-file-list> <!-- struts 过滤器 --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- spring 的监听器配置 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> </web-app>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zywyxd.html