springmvc搭建环境时报No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet with
当筵意气临九霄,星离雨散不终朝。这篇文章主要讲述springmvc搭建环境时报No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet with相关的知识,希望能为你提供帮助。
项目是使用spring MVC
(1)在浏览器中访问,后台总报错:
java代码
文章图片
- No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet with name ‘spring2‘
我是使用的注解。
spring mvc配置文件如下:
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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.2.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"
- >
- < !-- HandlerMapping -->
- < bean
- class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
- < !-- HandlerAdapter -->
- < bean
- class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
- < !-- ViewResolver -->
- < bean
- class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- < property name="viewClass"
- value="https://www.songbingjia.com/android/org.springframework.web.servlet.view.JstlView" />
- < property name="prefix" value="https://www.songbingjia.com/WEB-INF/jsp/" />
- < property name="suffix" value="https://www.songbingjia.com/android/.jsp" />
- < /bean>
- < mvc:annotation-driven />
- < !-- 处理器 -->
- < !-- < bean name="/hello" class="com.mvc.jn.controller.HelloWorldController"/> -->
- < context:component-scan base-package="com"/>
- < /beans>
文章图片
(2)这个问题解决之后,又报错:
No mapping found for HTTP request with URI [/exam3/WEB-INF/jsp/welcome.jsp] in DispatcherServlet with name ‘spring2‘
结果发现是web.xml配置得有问题,下面是有问题的:
Xml代码
文章图片
- < servlet>
- < servlet-name> spring2< /servlet-name>
- < servlet-class> org.springframework.web.servlet.DispatcherServlet< /servlet-class>
- < load-on-startup> 1< /load-on-startup>
- < /servlet>
- < servlet-mapping>
- < servlet-name> spring2< /servlet-name>
- < url-pattern> /*< /url-pattern>
- < /servlet-mapping>
推荐阅读
- android -------- 解决NDK开发中的 Method 'NewStringUTF' could not be resolved
- Android 测试 之adb shell
- Android 测试 之MonkeyRunner
- Android测试入门学习
- Android 测试之Monkey
- Mac下命令行下载android源代码并构建apk过程
- applicationContext.xml文件配置
- Android dumpsys命令详细使用
- Android Studio 上传GitHub项目失败后的一些问题