springMVC web工程之 HelloWorld
2017-05-06 17:50
260 查看
在搭建的过程中,发现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
4、src下新建springmvc.xml
5、controller和jsp
6、配置tomcat
(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
相关文章推荐
- springmvc + hibernate构建web工程
- 基于springmvc mybatis junit搭建分工程,分模块的web工程框架(二)
- 搭建Dynamic Web Project(动态web项目)的springmvc工程1
- 新建基于springMVC的javaweb工程项目(IDEA)
- Maven工程的SpringMVC结构的Web程序
- 基于springmvc mybatis junit搭建分工程,分模块的web工程框架(三)
- intellij idea springmvc web工程之helloworld
- 关于springmvc框架的web工程,从.xml到.java再到.jsp显示到网页上的过程,以及jsp静态文件的访问
- SpringMVC入门及HelloWorld工程实例
- 基于springmvc mybatis junit搭建分工程,分模块的web工程框架(一)
- 【spring in action 学习--springMVC搭建】在不使用web.xml的情况下,配置Srping MVC工程
- 搭建Dynamic Web Project(动态web项目)的springmvc工程1
- 快速搭建简单的springMvc框架的动态web工程
- Maven快速创建SpringMVC web工程详解(2)
- 搭建Dynamic Web Project(动态web项目)的springmvc工程2
- 搭建Dynamic Web Project(动态web项目)的springmvc工程2
- Maven快速创建SpringMVC web工程详解
- web工程过滤器和springMVC拦截器的一些总结
- MyBatis+JUnit测试Dao(Mapper)的用例实现( 不启动web工程 且 未使用SpringMVC管理MyBatis时 )
- web工程中使用proxool连接池