github地址:https://github.com/rongyaya10...html
不使用Maven,建立SSH(Spring+SpringMVC+Hibernate)的方法:java
IntelliJ ideagit
tomcatgithub
选择【Spring】 : Spring 、 Spring MVC 、 Web Application、Application Server、Hibernateweb
Spring和SpringMVC : 须要选择download,下载相关的jarspring
Web Application :会在WEB-INF下新建web.xml配置文件spring-mvc
Application Server:应用服务,配置Tomcattomcat
Hibernate:需选择download,下载jarmvc
下载jar,请稍等app
目录结构
【File】-【Project Structure】
在src下,新建main - java (java目录变动Sources)
若是在Problems中有标的数字,请点击,选择【fix】-【Add...】
选择目录下的【lib】文件夹
添加:
目录结构:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>*.form</url-pattern> </servlet-mapping> </web-app>
<?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-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <context:component-scan base-package="com.zgr.controller"/> <mvc:annotation-driven/> <mvc:default-servlet-handler/> <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/pages/"/> <property name="suffix" value=".jsp"/> </bean> </beans>
下载 jstl.jar 1.2 和 standard.jar 1.1.2
http://repo2.maven.org/maven2...
http://repo2.maven.org/maven2...
导入jar
选择Problems,点击【fix】
更改目录结构,增长target文件夹,编译后文件可存入这个文件夹
更改文件夹后,修改
修改war:
【controller】- 新建IndexController.java
package com.zgr.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller public class IndexController { @RequestMapping(value = "/", method = RequestMethod.GET) public String index() { return "index"; } }
【pages】 - index.jsp
<%-- Created by IntelliJ IDEA. User: zgr Date: 2017/7/26 Time: 15:16 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>web</title> </head> <body> web </body> </html>
运行:
成功!