说在前面的话
直到现在从Eclipse向IDEA转的人越来越多,但是IDEA的项目创建让人摸不清头脑,因此这里我创建一个非maven的ssm工程,供大家练练手,进一步的了解IDEA在项目中的使用。
创建项目
首先创建一个工程
选择java,图中画框框的多注意一下
创建工程的名字 SSMProject01
下面看一下原始的项目结构,很明显和Eclipse创建的项目部太一样,这里我们需要进行设置。
下面我们在WEB-INF下创建lib和classes两个文件夹,lib里存放jar包,classes里存放编译的文件。
把ssm需要的Jar包存放到lib中
创建完两个文件夹后我们再进行配置,也就是告诉编辑器lib和classes存放的位置。点击快捷键Ctrl+Shift+Alt+S或者点击图中的快捷按钮
接下来操作见图:
在src下创建一个IndexController.java文件
在WEB-INF下创建一个jsp文件夹,然后把index.jsp文件剪切过去。
编辑web.xml文件
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_4_0.xsd"
version="4.0">
SSMProject01
index.jsp
contextConfigLocation
classpath:applicationContext*.xml
org.springframework.web.context.ContextLoaderListener
CharacterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
utf-8
CharacterEncodingFilter
/*
SSMProject01
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:applicationContext.xml
1
SSMProject01
/
在src下创建一个applicationContext.xml文件
编辑applicationContext.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
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.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
编辑index.jsp文件
Created by IntelliJ IDEA.
User: Administrator
Date: 2019/2/5 0005
Time: 20:23
To change this template use File | Settings | File Templates.
--%>
您好,欢迎来到IDEAIDEA:您好${xiaofeng};
下面开始配置Tomcat。
启动tomcat
在浏览器输入http://localhost:8080/SSMProject01/gethtml
ssm非maven工程搭建成功,若您在操作的过程中有任何疑问,欢迎留言!!
下一期给大家介绍IDEA搭建mavenSSM工程。