Servlet中The requested resource is not available错误
自己为了测试servlet,用MyEclipse2015写了一个简单的登录程序。
1.登录页面index.jsp.
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String lUserName = (String)session.getAttribute("iUserName");
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta charset="utf-8">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head> <body>
<%
if (lUserName != ""&&lUserName!=null) {
%>
欢迎光临,<%=lUserName%>
<%
} else {
%>
<form name="loginfrm" action="loginserv" method="post">
用户名:<input type="text" name="username" value="zhangsan"><br>
密码:<input type="text" name="password" value="mm123456"><br>
<input type="submit" value="登录">
</form>
<%
}
%>
</body>
</html>
2.用模版写了一个servlet程序loginserv.java.
package com.kaly.servlet; import java.io.IOException;
import java.io.PrintWriter; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class loginserv extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html);charset=utf-8");
String getUser=request.getParameter("username");
String getpassword=request.getParameter("password");
PrintWriter pw=response.getWriter();
pw.print(getUser);
} }
这是一个很简单的程序,在收到请求后,把用户名打印出来。
3.运行出现问题:The requested resource is not available.

4.查找咨询,没有解决。后来查看web.xml。
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>loginserv</servlet-name>
<servlet-class>com.kaly.servlet.loginserv</servlet-class>
</servlet> <servlet-mapping>
<servlet-name>loginserv</servlet-name>
<url-pattern>/servlet/loginserv</url-pattern>
</servlet-mapping> </web-app>
因为这些都是自动生成,没有想到过会出现问题。不过记起以前写这个程序时<url-pattern>节点只是在<servlet-name>节点内容前多一个"/",尝试将其改为/loginserv,重启服务运行页面。一些正常。
总结:这应该是这种问题出现的其中一种解决途径。
Servlet中The requested resource is not available错误的更多相关文章
- 调用servlet报The requested resource is not available.
调用servlet的时候经常有这种报错,一般来说我直到现在遇到的情况大致有以下几类: 1.参数写错了 在新创建的servlet文件中有这么一行代码,“/LoginCheck”这个一定要和form表单中 ...
- 在IE浏览器输入测试servlet程序报:HTTP Status 404(The requested resource is not available)错
一.HTTP Status 404(The requested resource is not available)异常主要是路径错误或拼写错误造成的,请按以下步骤逐一排查: 1.未部署Web应用 2 ...
- 在k8s中安装flannel的故障解决: Failed to create SubnetManager: error retrieving pod spec for : the server does not allow access to the requested resource
花了一个上午来追踪问题,k8s都反复新建了十多次,docker都重启了几次.(一次显示不有获取磁盘空间,重启docker,清空存储解决) 在用kubeadm安装容器化的几个组件时,flannel组件死 ...
- (转)AJax跨域:No 'Access-Control-Allow-Origin' header is present on the requested resource
在本地用ajax跨域访问请求时报错: No 'Access-Control-Allow-Origin' header is present on the requested resource. Ori ...
- HTTP Status 404(The requested resource is not available)的几种解决方案
1. 未部署Web应用 2.URL输入错误 排错方法:首先,查看URL的IP地址和端口号是否书写正确.其次,查看上下文路径是否正确 Project--------Properties--- ...
- The requested resource (/) is not available解决办法
The requested resource (/) is not available HTTP Status 404(The requested resource is not available) ...
- 转:HTTP Status 404(The requested resource is not available)的几种解决方法
原文地址 原因:servlet没有配置正确 ,查看web.xml确认正确,以及自己的请求路径正确 在IE中提示“404”错误有以下三种情况 1.未部署Web应用 2.URL输入错误 排错方法: 首先, ...
- 分享HTTP Status 404(The requested resource is not available)的几种解决方案解决方法
下面是直接copy的,如果有什么疑问or补充,请不吝指教! 原文地址:http://www.myexception.cn/java-web/1480013.html 这个问题搞了我两天的时间,找了各种 ...
- 错误:“The requested resource () is not available.”的处置
做网页过程中,某页需要以新窗方式打开另一个网页,于是url是这样写: pages/test/transw/claimer.html 但是,点链接后网页提示 The requested resource ...
随机推荐
- S5PV210之GPIO模拟I2c时序之pcf8591与at24xx linux3.0.8驱动
目录:一. 说明 二. 驱动程序说明及问题 三. 案例一 四. 案例二 一. 说明 mini210开发板上带了at24c08, 看了linux内核自带的at24.c的驱动程序,编译下载到看 ...
- Python开发入门与实战20-微信开发配置
随着移动互联网时代的来临,微信已经成为移动互联网移动端的主要入口,现在很多的大型企业都有自己的微信服务号,如:银行业有自己的微银行,基金公司的公众服务号.通过微信入口可以方便快速的实现企业提供的服务. ...
- JDBC操作步骤及数据库连接操作
http://blog.csdn.net/joywy/article/details/7731305
- Spring Security 从配置入门 学习讲解。刽子手------------securityConfig.xml
不知道我的web.xml 大家都理解了没. 废话确实有点多,可能很多知识点,大家都知道,可是我学的时候,压根什么都不懂啊.... 这篇我们要讲刽子手 securityConfig. 为什么要说他是 ...
- xml配置文件的读写
using System.Xml; //----------------------------------------------读出XML文件中的节点值 XmlDocument xmlDoc = ...
- C语言程序设计第10堂作业
一.本次课主要内容: 本次课程学习数组,一种最基本的构造类型,它是一组相同类型数据的有序集合.数组中的元素在内存中连续存放,每个元素都属于同一种数据类型,用数组名和下标可以唯一地确定数组元素: (1) ...
- docker 源码分析 六(基于1.8.2版本),Docker run启动过程
上一篇大致了解了docker 容器的创建过程,其实主要还是从文件系统的视角分析了创建一个容器时需要得建立 RootFS,建立volumes等步骤:本章来分析一下建立好一个容器后,将这个容器运行起来的过 ...
- jquery+php+mysql实现Ajax省市县三级联动
1.第一步建立一个html页面的,放置省.市.县三个select选择框,代码如下: <!DOCTYPE html> <html> <head> <title& ...
- HTTP简介
HTTP协议是Hyper Text Transfer Protocol(超文本传输协议)的缩写,是用于从万维网(WWW:World Wide Web )服务器传输超文本到本地浏览器的传送协议.. HT ...
- wamp出现You don’t have permission to access/on this server提示的解决方法
本地搭建wamp 输入http://127.0.0.1访问正常,当输入http://localhost/ apache出现You don't have permission to access/on ...