HTTP Status 404 - /servlet/Item/AddItemServlet
我想学习编程的人对404和500都是非常敏感非常熟悉的。在做DRP系统的时候多次遇到这两个错误,今天让我遇到他并且让我铭记他,那就是一个“/”:
这是说jsp出问题了,并且找不到,学过java的同学都知道servlet/item是我建立servlet后的一个虚拟文件夹。配置文件都这么写:
<servlet>
<servlet-name>AddItemServlet</servlet-name>
<servlet-class>com.bjpowernode.drp.basedata.web.AddItemServlet</servlet-class>
</servlet> <servlet-mapping>
<servlet-name>AddItemServlet</servlet-name>
<url-pattern>/servlet/item/AddItemServlet</url-pattern>
</servlet-mapping>
上面的配置文件是没有问题的,以下是我的jsp中比較关键也比較easy出错,而我又出了错的地方:路径问题
<body class="body1">
<form name="itemForm" id="itemForm" action="<span style="background-color: rgb(255, 0, 0);">/servlet/item/AddItemServlet</span>" method="post" onsubmit="return validateForm(this)">
这个加红的地方看上去是没有问题,就是请求servlet,可是当我点击button要跳转时,却报错了,这就是加“/”与不加“/”的差别,由于我在jsp中增加了basePath(推荐博客),也就是web全路径:
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
path-------------------------------------------------------/servlet/Item/AddItemServlet
basePath---http+://+localhost+:+8181+/servlet/Item/AddItemServlet+/ (http://localhost:8181/servlet/Item/AddItemServlet)
而我在代码中又加了“/”这样之后,地址就变成http://localhost:8181//servlet/Item/AddItemServlet
所以大家能够看出一个“/”我们也不容忽视,这也成为我以后遇到问题的一个经验。分享了~~
HTTP Status 404 - /servlet/Item/AddItemServlet的更多相关文章
- 在IE浏览器输入测试servlet程序报:HTTP Status 404(The requested resource is not available)错
一.HTTP Status 404(The requested resource is not available)异常主要是路径错误或拼写错误造成的,请按以下步骤逐一排查: 1.未部署Web应用 2 ...
- Spring MVC 使用问题与解决--HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
1.HTTP Status 500 - Servlet.init() for servlet springmvc threw exception 解决 使用jre1.7 Spring4.3 2.spr ...
- web项目引用Java项目,连接报错error HTTP Status 500 - Servlet execution threw an exception
错误信息 项目背景: 一个web项目引用一个java Project,项目中添加了引用,但是打开页面访问,总报500错误.提示:servlet初始化错误. 环境:Eclipse luna JDK: 1 ...
- TOMCAT报错:HTTP Status 404 -
构建struts2工程师,tomcat报错: HTTP Status 404 - type Status report message description The requested resour ...
- HTTP Status 500 - Servlet.init() for servlet htmlWebConfig threw exception
HTTP Status 500 - Servlet.init() for servlet htmlWebConfig threw exception
- Jsp——http status 404 问题
今天学习Jspapplication内置对象的时候突然碰到了一个问题——http status 404 发生了什么? 提示The requested resource is not available ...
- 在写ssh项目时浏览器页面出现http status 404 – not found
HTTP Status 404 - /streetManager/index.jsp type Status report message /streetManager/index.jsp descr ...
- 报错如HTTP Status 404 - /ssh_crm/jsp/linkman/add.jsp/
明显是写错了, HTTP Status 404 - /ssh_crm/jsp/linkman/add.jsp/ 应该改成 HTTP Status 404 - /ssh_crm/jsp/linkman/ ...
- 68. 使用thymeleaf报异常:Not Found, status=404【从零开始学Spring Boot】
[从零开始学习Spirng Boot-常见异常汇总] 我们按照正常的流程编码好了 controller访问访问方法/hello,对应的是/templates/hello.html文件,但是在页面中还是 ...
随机推荐
- poj1286 Necklace of Beads【裸polya】
非常裸的polya,只是我看polya看了非常久 吉大ACM模板里面也有 #include <cstdio> #include <cmath> #include <ios ...
- 一个JavaWeb项目中使用的部分技术
-- 2015年8月8日 1. Web框架: Spring+ SpringMVC + MyBatis Spring: 作为容器.工厂,用于解耦以及管理对象生命周期. 整合各类框架和依赖. MVC : ...
- 杂项-DB:数据挖掘
ylbtech-杂项-DB:数据挖掘 数据挖掘(Data mining)又译为资料探勘.数据采矿.它是数据库知识发现(英语:Knowledge-Discovery in Databases,简称:KD ...
- SQL语句之Insert
插入常见的3种形式: 单条插入, 批量插入, 返回刚插入行的id http://www.cnblogs.com/yezhenhan/archive/2011/08/17/2142948.html
- python中数字的排序
lst = [2,22,4,7,18]for j in range(len(lst)): #记录内部排序的次数 i = 0 while i < len(lst)-1: if lst[i] > ...
- POJ 2923 DP
题意: 两辆车去运一堆货物,货物数量小于等于10,问最少需要几趟能把货物全部运到目的地. 思路: 思路很简单,就是状态压缩成二进制.判断一下每个状态能不能运输.再进行一下DP. 设s[]数组里记录所有 ...
- Android WebView访问网站携带登录认证Cookies和动态自定义的cookies
最近项目几个页面要复用微信程序的网页.但是需要调用微网站登录接口,返回Cookies,webview访问需要的网页的时候携带. 并且还需要几个其他的动态改变的cookie,目的是根据这几个动态自定义c ...
- idea的项目中output框出现乱码
找到tomcat的安装目录中的logging.properties 我的在这里:E:\tools\tomcat\apache-tomcat-8.5.38\conf 改其中的参数 修改前 java.u ...
- UNP学习笔记3——基本UDP套接字编程
1 概述 TCP和UDP网络编程存在一些本质的差异,主要是由于传输层的差别:UDP是无连接的不可靠的数据报协议,而TCP是面向连接的字节流协议. 下图是典型的UDP客户端和服务器之间的通信流程.客户不 ...
- node——含有异步函数的函数封装
在写代码时我们会发现有大量的重复代码,为了使代码更加简洁,我们可以将重复的代码封装为一个可以在多个部分时候用的函数. 之前写的新闻代码中,经常出现的操作有对文件的读取,我们可以将它封装为一个函数rea ...