springMvc配置tomcat时出现"No Spring WebApplicationInitializer types detected on classpath" 解决方法
来源:互联网 发布:数据共享与交换 编辑:程序博客网 时间:2024/06/08 17:25
通过maven插件配置springMvc的tomcat启动时,出现"No Spring WebApplicationInitializer types detected on classpath" 的问题,查询了好多都无法很好的解决,在不断的尝试下,终于找到了解决方法。
下面给出我的web.xml 文件,在web.xml文件中添加下面的绿色代码即可,即添加listener,加载springmvc-servlet.xml配置文件。
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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_3_0.xsd" version="3.0" metadata-complete="true"> <display-name>Archetype Created Web Application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc-servlet.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>SpringMvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>SpringMvc</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping></web-app>
springmvc-servlet.xml为你自定义的dispatcher-servlet.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.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <mvc:annotation-driven/> <context:component-scan base-package="com.controller" /> <context:annotation-config /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/pages/" /> <property name="suffix" value=".jsp" /> </bean></beans>
下面是我的controller代码
import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;@Controllerpublic class HelloController { @RequestMapping("/hello") @ResponseBody public String printHello(){
return "hello wtf mvc"; }}
简单的记录一下,有问题了再来记录,多交流。
阅读全文
0 1
- springMvc配置tomcat时出现"No Spring WebApplicationInitializer types detected on classpath" 解决方法
- No Spring WebApplicationInitializer types detected on classpath
- No Spring WebApplicationInitializer types detected on classpath
- "No Spring WebApplicationInitializer types detected on classpath" 解决方案
- SSH整合:No Spring WebApplicationInitializer types detected on classpath
- 关于No Spring WebApplicationInitializer types detected on classpath的提示
- Tomcat未启动成功,显示No Spring WebApplicationInitializer types detected on classpath
- 启动报错:spring No Spring WebApplicationInitializer types detected on classpath
- 关于 No Spring WebApplicationInitializer types detected on classpath卡死的解决办法
- Picasso detected an unsupported OkHttp on the classpath的解决方法
- 利用WebApplicationInitializer配置SpringMVC取代web.xml
- 利用WebApplicationInitializer配置SpringMVC取代web.xml
- 在OkHttp的使用过程中出现下列问题Picasso detected an unsupported OkHttp on the classpath.
- 在OkHttp的使用过程中出现下列问题Picasso detected an unsupported OkHttp on the classpath.
- 在OkHttp的使用过程中出现下列问题Picasso detected an unsupported OkHttp on the classpath.
- Spring 出现No WebApplicationContext found解决方法
- No system tray detected on this system
- Spring 配置Thymeleaf时出现ServletContextTemplateResolver no Matching constructor.....
- HTML5 和CSS3 基础知识
- 光敏电阻的一些特性
- hdu 2473 Junk-Mail Filter
- TCP/IP协议族【第三章底层技术】
- Android 事件分发机制
- springMvc配置tomcat时出现"No Spring WebApplicationInitializer types detected on classpath" 解决方法
- 如何编写属于自己的adb shell 命令。
- OpenWRT 编译 error GNU libiconv not in use but included iconv.h is from libiconv
- HDOJ 1282 回文数猜想
- MyBatis注解方式与映射文件方式配合实现一对一,一对多,多对多(三)
- 学习MySQL的一些记录笔记(2)11-06
- Android Logcat 分段打印较长的文本
- JAVA面试题通关点
- 关于this.getHibernateTemplate().update(entity)