jsp跳转到servlet页面后显示无法显示此页面

lmy497196404 2018-09-10 05:27:48
JSP页面:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>登陆</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">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

<style type="text/css">
<!--
#a{
margin: auto auto;
text-align: center;
}
-->
</style>

</head>

<body>
<form method="post" action="/shixun/Lfind">
<div id="a">
用户名:<input type="text" name="name" size="20" maxlength="18"><br/>
密   码:<input type="password" name="password" size="20" maxlength="18"><br/>
<div id="a">
<input name="submit" type="submit" class="buttom" value="提交">
<input name="reset" type="reset" class="buttom" value="重置">
<a href="login/zhuce.jsp"><input type="button" value="注册"></a>
</div>
</div>
</form>
</body>
</html>

servlet页面:
package loginservlet;

import java.io.IOException;
import java.util.List;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.dengluDao;
import Bean.login;

public class Lfind extends HttpServlet {

/**
* Constructor of the object.
*/
public Lfind() {
super();
}

/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}

/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}

/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html");
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
String name=request.getParameter("name");
String password = request.getParameter("password");
response.sendRedirect("index.jsp");
if(name != null && password != null){
dengluDao goodsDao=new dengluDao();
List<login> list=goodsDao.findAll("select * from users where name='"+name+"'");
if(list.equals(name) && list.equals(password)){
response.sendRedirect("index.jsp");
return;
}
}



out.flush();
out.close();
}

/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}

}

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/java2ee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<jsp-config>
<jsp-property-group>
<description>html encoding</description>
<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>Linsert</servlet-name>
<servlet-class>loginservlet.Linsert</servlet-class>
</servlet>
<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>Lfind</servlet-name>
<servlet-class>loginservlet.Lfind</servlet-class>
</servlet>


<servlet-mapping>
<servlet-name>Linsert</servlet-name>
<url-pattern>/servlet/Linsert</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Lfind</servlet-name>
<url-pattern>/servlet/Lfind</url-pattern>
</servlet-mapping>
<display-name>JSPConfiguration</display-name>
<url-pattern>*.html</url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>UTF-8</page-encoding>
<scripting-invalid>false</scripting-invalid>
<include-prelude></include-prelude>
<include-coda></include-coda>
</jsp-property-group>
</jsp-config>
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
登陆界面正常进入,但是无论输入什么都会显示错误400,无法显示此页面,管理界面没有进行编写打开后仅显示一句hallo,其他servlet未与这几个页面有联系便不再复制。
...全文
688 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
讨厌走开啦 2018-09-11
  • 打赏
  • 举报
回复
看下后台的日志,servlet是否被正常访问,如果被正常访问,是否报错,如果没有正常访问,那一般是访问路径出错了。
lmy497196404 2018-09-10
  • 打赏
  • 举报
回复
数据库中账号密码都是admin

87,963

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧