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>
運行:
成功!