springMVC web工程之 HelloWorld
来源:互联网 发布:esp8266的单片机教程 编辑:程序博客网 时间:2024/06/05 10:34
在搭建的过程中,发现IDEA找不到Tomcat,这是因为IDEA的社区版本会有有缺失,需要自行安装。
(1)如果Edit Configurations 点+ 号并没有找到Tomcat, 则可能Tomcat并没有启用。
在Preferences->Plugins搜索tomcat并启用就可以了。如下图
(2)如果IDEA并没有集成tomcat的话,需要手动下载。然后在Edit Configurations->Tomcat Server->Server->Configure中配置路径。
1、新建java工程
2、设置项目
2、添加jar包
3、配置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"> <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- 配置 DispatcherServlet 的一个初始化参数: 配置 SpringMVC 配置文件的位置和名称 --> <!-- 实际上也可以不通过 contextConfigLocation 来配置 SpringMVC 的配置文件, 而使用默认的. 默认的配置文件为: /WEB-INF/<servlet-name>-servlet.xml --> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping></web-app>
4、src下新建springmvc.xml
<?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.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.spring.controller"></context:component-scan> <!-- 配置视图解析器: 如何把 handler 方法返回值解析为实际的物理视图 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"></property> <property name="suffix" value=".jsp"></property> </bean></beans>
5、controller和jsp
6、配置tomcat
0 0
- springMVC web工程之 HelloWorld
- 创建一个helloworld springmvc的web工程
- 【springmvc】 springmvc 之 HelloWorld
- springmvc之HelloWorld
- 剖析springmvc之HelloWorld
- springmvc之helloworld
- SpringMVC之HelloWorld
- SpringMVC实例之HelloWorld
- SpringMVC之“HelloWorld”起步
- springmvc之helloworld
- SpringMVC之HelloWorld。
- SpringMVC框架之HelloWorld
- SpringMVC入门及HelloWorld工程实例
- Web Worker之HelloWorld
- Maven+SpringMVC整合之helloworld
- Maven+SpringMVC整合之helloworld
- Maven+SpringMVC整合之helloworld
- Maven+SpringMVC整合之helloworld
- 二叉树的递归与非递归
- Git常用指令笔记
- ABAP 中JSON格式的转换与解析
- 类型转换构造函数隐式调用与运算符重载参数类型的不对应
- 漫谈程序员系列:程序员该不该考虑初创公司
- springMVC web工程之 HelloWorld
- [知识点滴]HTML5元素垂直居中那些事?
- java多线程(二)
- 商品展示案例的ShopShowDemo
- js 解决js for 循环中的闭包问题
- python之字典
- ZOJ-1091-Knight Moves
- 这不是我想要的ABAP开发者
- poj 1743