我想学习编程的人对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的更多相关文章

  1. 在IE浏览器输入测试servlet程序报:HTTP Status 404(The requested resource is not available)错

    一.HTTP Status 404(The requested resource is not available)异常主要是路径错误或拼写错误造成的,请按以下步骤逐一排查: 1.未部署Web应用 2 ...

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

  3. web项目引用Java项目,连接报错error HTTP Status 500 - Servlet execution threw an exception

    错误信息 项目背景: 一个web项目引用一个java Project,项目中添加了引用,但是打开页面访问,总报500错误.提示:servlet初始化错误. 环境:Eclipse luna JDK: 1 ...

  4. TOMCAT报错:HTTP Status 404 -

    构建struts2工程师,tomcat报错: HTTP Status 404 - type Status report message description The requested resour ...

  5. HTTP Status 500 - Servlet.init() for servlet htmlWebConfig threw exception

    HTTP Status 500 - Servlet.init() for servlet htmlWebConfig threw exception

  6. Jsp——http status 404 问题

    今天学习Jspapplication内置对象的时候突然碰到了一个问题——http status 404 发生了什么? 提示The requested resource is not available ...

  7. 在写ssh项目时浏览器页面出现http status 404 – not found

    HTTP Status 404 - /streetManager/index.jsp type Status report message /streetManager/index.jsp descr ...

  8. 报错如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/ ...

  9. 68. 使用thymeleaf报异常:Not Found, status=404【从零开始学Spring Boot】

    [从零开始学习Spirng Boot-常见异常汇总] 我们按照正常的流程编码好了 controller访问访问方法/hello,对应的是/templates/hello.html文件,但是在页面中还是 ...

随机推荐

  1. emacs使用本地emacs server模式打开远程文件

    使用emacs的用户都知道,一般要打开远程机器上的文件要使用TrampMode模式,调用方式例如以下: C-x C-f /remotehost:filename RET (or /method:use ...

  2. Codeforces 558B Amr and The Large Array

    B. Amr and The Large Array time limit per test 1 second memory limit per test 256 megabytes input st ...

  3. Codeforces Round #260 (Div. 1) 455 A. Boredom (DP)

    题目链接:http://codeforces.com/problemset/problem/455/A A. Boredom time limit per test 1 second memory l ...

  4. oracle经常使用函数(2)

    1.TRIM([ { { LEADING | TRAILING | BOTH }[ trim_character ]| trim_character} FROM ]trim_source) 函数 參数 ...

  5. unity坐标转换问题

    unity最经常使用的几种坐标.屏幕坐标.世界坐标.ngui坐标,相对于父物体的坐标(localPoisition). 可是有时候这几种坐标相互转换何其困难,让自己狠抓头. 不得不操作的方式是创建虚拟 ...

  6. WCF:目录

    ylbtech-WCF:目录 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   作者:ylbtech出处:http://ylbtech.c ...

  7. BZOJ 2957 分块

    思路: 记录每栋楼楼顶与原点连线的斜率 那么一栋楼可见当且仅当前面所有楼的斜率都小于这栋楼 将n栋楼分为√(0.5*n*logn)块 每一块内维护一个单调上升子序列(注意不是LCS) 比如说4 1 2 ...

  8. avformat_find_stream_info函数卡住问题

    问题:初始化RTSP流时,在android设备上卡住在avformat_find_stream_info函数,然后程序崩溃. 但其他URL没问题,且同样在代码在iOS上没问题,由于jni调试,也没看到 ...

  9. HD-ACM算法专攻系列(20)——七夕节

    问题描述: AC源码: /**/ #include"iostream" #include"cmath" using namespace std; int mai ...

  10. 【转】如何使用windows的计划任务?计划任务?

    我们经常有一些程序想要过了几小时来运行:比如定时关机 或者说希望能够每天的几点执行一个什么程序: 这些所有的操作都需要用到windows的任务计划:或者叫计划任务:反正都一样 下面小编将指导大家创建一 ...