Intellij idea 开发第一个springMVC demo
来源:互联网 发布:淘宝鲜花网 编辑:程序博客网 时间:2024/06/05 09:21
第一个springMVC例子
主要目的是熟悉intellij的web项目操作和springMVC的基本概念
具体操作如下:
1.创建intellij idea web module
然后填写module名 点击确认 module创建完毕
2.在module的web-WEB-INF下新建 classes和lib文件夹
2.修改项目的配置 点击file->Project Struture 修改Modules下的paths 修改完毕点击OK
3.配置tomcat 点击run->edit configurations
点绿色的十字图标 创建tomcat并配置
4.首先配置web.xml
<?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"> <!--配置dispatcherservlet 以及mapping--> <servlet> <servlet-name>mvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mvc</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping></web-app>
5.配置mvc-servelet
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:component-scan base-package="com.jsu.mvc" /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix"> <!-- 这个配置是配置JSP页面的位置,按照你自己的配置来配 --> <!--jsp文件夹需要自己手动创建--> <value>/WEB-INF/jsp/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean></beans>
6.在jsp目录下新建hello.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %><html><head> <title>hello mvc</title></head><body>${msg }</body></html>
7.在src中编写controller类
@Controllerpublic class HelloController { @RequestMapping(value="/hello",method = RequestMethod.GET) public String printWelcome(ModelMap model) { model.addAttribute("msg", "Spring 3 MVC Hello World"); return "hello"; }}
最后进行测试
第一个小demo到此结束!
0 0
- Intellij idea 开发第一个springMVC demo
- 使用IntelliJ IDEA的第一个MyBatis Demo
- 使用Intellij Idea创建第一个SpringMVC工程
- Intellij IDEA开发第一个android应用教程
- Intellij IDEA开发第一个android应用教程
- Intellij IDEA开发第一个android应用教程
- Intellij IDEA开发第一个android应用教程
- Intellij-IDEA-maven+springMVC+mybatis整合DEMO
- MyBatis学习笔记(一)IntelliJ IDEA的第一个MyBatis Demo
- IntelliJ IDEA 创建第一个Mybatis工程
- Intellij Idea 创建第一个Web项目
- 使用IntelliJ IDEA开发SpringMVC网站
- 使用IntelliJ IDEA开发SpringMVC网站
- IntelliJ IDEA开发SpringMVC网站(上)
- IntelliJ IDEA开发SpringMVC网站(下)
- 使用IntelliJ IDEA开发SpringMVC网站
- 使用IntelliJ IDEA开发SpringMVC网站
- 使用IntelliJ IDEA开发Maven SpringMVC网站
- 趣味javascript程序
- TextView设置字间距和行间距
- Hadoop 配置本篇主要就是配置HDFS和YARN
- 【Hadoop代码笔记】Hadoop作业提交之客户端作业提交
- iOSAPP跳转到qq聊天界面
- Intellij idea 开发第一个springMVC demo
- oracle基本操作符/运算符/操作语言...
- GET POST PUT DELETE 含义与区别
- 导入maven项目,报错Cannot read lifecycle mapping metadata for artifact org.apache.maven.plugins:maven-clean
- QT学习之 如何启动一个线程
- C#(二)
- Hadoop完全分布式集群搭建
- IntelliJ IDEA WEB项目的部署配置
- 乐观锁与悲观锁的区别