No mapping found for HTTP request with URI [/zjic] in DispatcherServlet

简介: 最近做项目 出现了前台访问出现404 控制台出现 No mapping found for HTTP request with URI [/zjic] in DispatcherServlet

web.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">

 <display-name>zjic</display-name>

 <servlet>

   <servlet-name>zjic</servlet-name>

   <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

   <load-on-startup>1</load-on-startup>

 </servlet>

 

 <servlet-mapping>

   <servlet-name>zjic</servlet-name>

   <url-pattern>/*</url-pattern>

 </servlet-mapping>

 

 <context-param>

 <param-name>contextConfigLocation</param-name>

 <param-value>/WEB-INF/zjic-servlet.xml</param-value>

</context-param>

 <listener>

   <listener-class>

     org.springframework.web.context.ContextLoaderListener

   </listener-class>

 </listener>

 

 <welcome-file-list>

   <welcome-file>index.jsp</welcome-file>

 

 </welcome-file-list>

 

 

<!-- Session超时  -->

<session-config>

 <session-timeout>-1</session-timeout>

</session-config>

</web-app>


最终找到原因 把


<servlet-mapping>

   <servlet-name>zjic</servlet-name>

   <url-pattern>/*</url-pattern>

 </servlet-mapping>


改为


<servlet-mapping>

   <servlet-name>zjic</servlet-name>

   <url-pattern>/</url-pattern>

 </servlet-mapping>


即/* 去掉*  可以访问jsp

但是发现无法访问静态资源 很郁闷


一月 25, 2016 12:57:41 上午 org.springframework.web.servlet.DispatcherServlet noHandlerFound

警告: No mapping found for HTTP request with URI [/Extjs5SSM/lib/js/app/app.js] in DispatcherServlet with name 'extjs'

一月 25, 2016 12:57:41 上午 org.springframework.web.servlet.DispatcherServlet noHandlerFound

警告: No mapping found for HTTP request with URI [/Extjs5SSM/lib/js/ext-5.1.0/ext-all.js] in DispatcherServlet with name 'extjs'

等等

11.png

参考 http://blog.163.com/zhangmihuo_2007/blog/static/27011075201453044959574?suggestedreading

解决了这个问题:

12.png

静态资源都在lib下面


因此在spring配置文件中加入



<!-- 静态资源访问 -->

<mvc:resources location="/lib/" mapping="/lib/**"/>



只需要映射webroot 下一层子目录即可

如果有多个 可以写多个mvc:resources




解决了这个问题

此时.do 访问可能出现404

参考http://blog.csdn.net/w605283073/article/details/50583978


相关文章
|
7月前
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must b
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must b
81 0
|
4月前
|
监控 搜索推荐 定位技术
HTTP状态码:如何修复 404 Not Found错误?
互联网上各种类型的网站非常多,无论用户还是网站运营者不可避免的会遇到404 Not Found错误,如果遇到404错误,我们应该如何解决呢?
32 1
|
Java
The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案
The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案
378 0
The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案
|
9月前
|
缓存 Linux 开发工具
centos 7 yum安装失败(HTTP Error 404 - Not Found)的解决方法
centos 7 yum安装失败(HTTP Error 404 - Not Found)的解决方法
605 0
|
Java 应用服务中间件 Apache
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path类似问题简单解决方案
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path类似问题简单解决方案
240 0
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path类似问题简单解决方案
|
Java Maven
maven jsp报错javax.servlet.http.HttpServlet“ was not found on the Java Build Path
maven jsp报错javax.servlet.http.HttpServlet“ was not found on the Java Build Path
118 0
|
Java 应用服务中间件 Apache
springMvc14-the superclass “javax.servlet.http.HttpServlet” was not found
springMvc14-the superclass “javax.servlet.http.HttpServlet” was not found
91 0
|
10天前
|
XML Java 数据格式
Servlet 教程 之 Servlet 客户端 HTTP 请求 3
该教程展示了如何在Servlet中处理客户端HTTP请求,特别是获取HTTP头信息。示例代码创建了一个名为`DisplayHeader`的Servlet,它扩展了`HttpServlet`并重写了`doGet`方法。在`doGet`中,使用`HttpServletRequest`的`getHeaderNames()`遍历所有头部,显示其名称和对应值。Servlet在TomcatTest项目下,通过`web.xml`配置映射到`/TomcatTest/DisplayHeader`路径。
29 14
|
10天前
|
安全 Java 网络安全
Servlet 教程 之 Servlet 客户端 HTTP 请求 2
Servlet教程介绍了如何在Servlet中处理HTTP请求,包括获取Cookie、头信息、参数、Session等。方法如:`getCookies()`、`getAttributeNames()`、`getHeaderNames()`、`getParameterNames()`等。还能获取身份验证类型、字符编码、MIME类型、请求方法、远程用户信息、URL路径、安全通道状态以及请求内容长度等。此外,可通过`getSession()`创建或获取Session,并以`Map`形式获取参数。
21 8
|
2天前
|
JSON 编解码 Go
Golang深入浅出之-HTTP客户端编程:使用net/http包发起请求
【4月更文挑战第25天】Go语言`net/http`包提供HTTP客户端和服务器功能,简化高性能网络应用开发。本文探讨如何发起HTTP请求,常见问题及解决策略。示例展示GET和POST请求的实现。注意响应体关闭、错误处理、内容类型设置、超时管理和并发控制。最佳实践包括重用`http.Client`,使用`context.Context`,处理JSON以及记录错误日志。通过实践这些技巧,提升HTTP编程技能。
16 1