c语言sscanf函数的用法是什么
263
2023-02-10
通过IEAD+Maven快速搭建SSM项目的过程(Spring + Spring MVC + Mybatis)
项目效果预览:
通过访问控制层的test/dologin方法进入index.jsp,展示jsp中的“hello,ssm”内容
一、新建项目:
1.打开IDEA,新建一个Maven项目
2.点击next,新建一个为ssmDemo的Maven项目(自己定义项目GroupId和ArtifactId)
3.配置本地Maven路径
4.点击Next,确认项目信息,配置项目名称和项目路径,点击Finish按钮即可创建项目
5.项目创建完成,目录结构如下:
注:如项目目录中未包含src,则项目还在初始化,注意网络连接,稍等片刻即可
二、补充项目结构:
1.在main文件夹下面创建java和resources文件夹
2.使java文件夹为项目资源文件夹(Sources root)
3.使resources文件夹为Resources root
4.在src/java目录下面创建com包,在com包创建controller、dao、po、service、service.impl包
三、完善pom.xml(添加项目依赖--完整pom.xml代码)
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
效果图:
注1:代码复制完成后,选择右下角的Import Changes
注2:如Import Changes后External还未出现jar包,则选中项目,右键,选择maven,Generate Sources...
四、为项目导入jar包
1.选择项目右键 -- open Module Setting
2.选择Artifact
3.选择项目名,选择outPut LayOut,选择Available Elements -- 选择项目名称 -- 右键 -- put into...
效果图(WEB-INF中添加了lib目录):
五、完善target文件夹
1.选择右侧侧栏的maven
2.选择Lifecycle -- 选择clean(双击)
3.选择Lifecycle -- 选择install(双击)
4.效果图
六、测试项目
1.添加tomcat(run --> editConfigurations --> 点击+ --> 选择tomcat-- local)
2.配置Deployment(点击Deployment -- 选择右下角+ -- 选择Artifact --选择Artifa)
3.配置访问路径:/ssmDemotest
4.启动tomcat,访问:http://localhost:8080/ssmDemotest
七、编写ssm框架所需xml
1.在src/resources文件夹下面添加mybatis包、spring包
2.在src/resources文件夹下面添加log4j.properties、db.properties
3.在mybatis包下添加:mybatis-config.xml
"http://mybatis.org/dtd/mybatis-3-config.dtd">
4.在spring包下添加:spring-dao.xml
xmlns:context="http://springframework.org/schema/context" xmlns:p="http://springframework.org/schema/p" xmlns:aop="http://springframework.org/schema/aop" xmlns:tx="http://springframework.org/schema/tx" xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans-4.0.xsd http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.0.xsd http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop-4.0.xsd http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx-4.0.xsd http://springframework.org/schema/util http://springframework.org/schema/util/spring-util-4.0.xsd">
xmlns:context="http://springframework.org/schema/context" xmlns:p="http://springframework.org/schema/p"
xmlns:aop="http://springframework.org/schema/aop" xmlns:tx="http://springframework.org/schema/tx"
xmlns:xsi="http://w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans-4.0.xsd
http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.0.xsd
http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop-4.0.xsd
http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx-4.0.xsd
http://springframework.org/schema/util http://springframework.org/schema/util/spring-util-4.0.xsd">
5.在spring包下添加:spring-service.xml
xmlns:context="http://springframework.org/schema/context" xmlns:p="http://springframework.org/schema/p" xmlns:aop="http://springframework.org/schema/aop" xmlns:tx="http://springframework.org/schema/tx" xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans-4.0.xsd http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.0.xsd http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop-4.0.xsd http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx-4.0.xsd http://springframework.org/schema/util http://springframework.org/schema/util/spring-util-4.0.xsd">
xmlns:context="http://springframework.org/schema/context" xmlns:p="http://springframework.org/schema/p"
xmlns:aop="http://springframework.org/schema/aop" xmlns:tx="http://springframework.org/schema/tx"
xmlns:xsi="http://w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans-4.0.xsd
http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.0.xsd
http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop-4.0.xsd
http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx-4.0.xsd
http://springframework.org/schema/util http://springframework.org/schema/util/spring-util-4.0.xsd">
6.在spring包下添加:spring-mvc.xml
xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:p="http://springframework.org/schema/p" xmlns:context="http://springframework.org/schema/context" xmlns:mvc="http://springframework.org/schema/mvc" xsi:schemaLocation="http://springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://springframework.org/schema/mvc http://springframework.org/schema/mvc/spring-mvc-4.0.xsd http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.0.xsd">
xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:p="http://springframework.org/schema/p"
xmlns:context="http://springframework.org/schema/context"
xmlns:mvc="http://springframework.org/schema/mvc"
xsi:schemaLocation="http://springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://springframework.org/schema/mvc http://springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.0.xsd">
7. 完善web.xml
xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID"
version="2.5">
八、启动tomcat,测试xml文件是否正确
1.如启动日志没有错误信息,则xml添加无误
2.如网址:http://localhost:8080/ssmDemotest 正常展示,则xml添加无误
注:由于大部分代码均为复制,可以重启IDEA
九、controller层
1.在controller包新建类:TestController
2.在类顶部(导包语句下面)添加注解:@Controller,@RequestMapping(value = "test")
3.编写方法:
@RequestMapping("dologin")
public String dologin() {
System.out.println("====test====");
return "index";
}
十、JSP
1.在web-inf下创建目录:jsp
2.在jsp文件下创建:index.jsp
3.在index.jsp下添加:hello,ssm
十一、测试
http://localhost:8080/ssmDemotest/test/dologin
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~