| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3123 人关注过本帖
标题:求助!!ecplise中出现 Description The origin server did not find a cur ...
只看楼主 加入收藏
a醒着做梦
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-5-18
结帖率:100%
收藏
已结贴  问题点数:1 回复次数:4 
求助!!ecplise中出现 Description The origin server did not find a current representati
刚开始学习有关java web的内容,在联系连接MySQL数据库,然后实现简单的登录页面,但是页面跳转不了,请问这是什么原因,哪个大神能来指点一下!!!
===============================================================================================================
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    <form action="DengLuServlet" method="post">
        <input type="text" name="sname" /><br/>
        <input type="password" name="spwd" "/><br/>
        <input type="submit" value="登录"/>
    </form>
</html>
==========================================================================================================

DengLuServlet.java

package servlet;

import
import java.sql.SQLException;

import javax.servlet.ServletException;

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

import dao.StudentDao;
import users.Student;



/**
 * Servlet implementation class RegServlet
 */

public class DengLuServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
      
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DengLuServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        

    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        request.setCharacterEncoding("utf-8");
        
        String username=request.getParameter("sname");
        String pwd=request.getParameter("spwd");

        Student st = new Student();
        StudentDao dao=new StudentDao();
        try {
            st=dao.getStudentOne(username,pwd);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if(st == null)
            response.sendRedirect("fail.jsp");
        else
            response.sendRedirect("exam.jsp");

    }

}


========================================================================

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www. xmlns="http://xmlns. xsi:schemaLocation="http://xmlns. http://xmlns. id="WebApp_ID" version="3.1">
  <display-name>denglu</display-name>
  
  <servlet>
      <servlet-name>DengluServlet</servlet-name>
      <servlet-class>DengluServlet</servlet-class>
  </servlet>
  <servlet-mapping>
      <servlet-name>DengluServlet</servlet-name>
      <url-pattern>/DengluServlet</url-pattern>   
  </servlet-mapping>
  
  <servlet>
      <servlet-name>LoginServlet</servlet-name>
      <servlet-class>servlet.LoginServlet</servlet-class>
  </servlet>
  <servlet-mapping>
      <servlet-name>LoginServlet</servlet-name>
      <url-pattern>/LoginServlet</url-pattern>   
  </servlet-mapping>
</web-app>
搜索更多相关主题的帖子: request http import servlet response 
2020-05-18 17:54
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:1 
配置文件web.xml的<servlet-class>要写类的全程,包括所在包路径

另外,有问题的帖子要把报错贴上来

剑栈风樯各苦辛,别时冰雪到时春
2020-05-18 18:27
a醒着做梦
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-5-18
收藏
得分:0 
回复 2楼 林月儿
好的,这是我改完后的路径,路径改完后还是会出现
===============================================
HTTP Status 404 – Not Found
Type Status Report
Message /denglu/DengLuServlet
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
=========================================================================================
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www. xmlns="http://xmlns. xsi:schemaLocation="http://xmlns. http://xmlns. id="WebApp_ID" version="3.1">
  <display-name>denglu</display-name>
  
  <servlet>
      <servlet-name>DengluServlet</servlet-name>
      <servlet-class>servlet.DengluServlet</servlet-class>
  </servlet>
  <servlet-mapping>
      <servlet-name>DengluServlet</servlet-name>
      <url-pattern>/DengluServlet</url-pattern>   
  </servlet-mapping>
  
  <servlet>
      <servlet-name>LoginServlet</servlet-name>
      <servlet-class>servlet.LoginServlet</servlet-class>
  </servlet>
  <servlet-mapping>
      <servlet-name>LoginServlet</servlet-name>
      <url-pattern>/LoginServlet</url-pattern>   
  </servlet-mapping>
</web-app>
==========================================================================
求大神指点!!!
2020-05-18 18:47
a醒着做梦
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-5-18
收藏
得分:0 
StudentDao.java 里面的getStudentOne(username,pwd)方法
======================================================================================
public Student getStudentOne(String sname,String spwd) throws SQLException   {
        Connection conn = DBManager.getConnection();
        PreparedStatement pstmt = null;
        ResultSet rs = null;

        Student student = new Student();

        try {
            String sql = "SELECT * FROM yonghu where sname=? and spwd=?";
            pstmt = conn.prepareStatement(sql);
            pstmt.setString(1, sname);
            pstmt.setString(2, spwd);
            
            rs = pstmt.executeQuery();
            while (rs.next()) {
/**
                student.setSno(rs.getString("sno"));
                student.setSname(rs.getString("sname"));
                student.setSsex(rs.getString("spwd"));
                student.setSaddress(rs.getString("saddress"));
                student.setShobby(rs.getString("shobby"));
                student.setSdept(rs.getString("sdept"));

                student.setSnation(rs.getInt("snation"));
                student.setSage(rs.getInt("sage"));

    **/
                student.setSname(rs.getString("sname"));
                student.setSpwd(rs.getString("spwd"));
               
                }
            return student;
        } catch (SQLException e) {
            //e.printStackTrace();
            throw e;
        } finally {
            DBManager.closeJDBC(rs, pstmt, conn);
        }
        
    }
2020-05-18 18:58
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:0 
eclipse的控制台报什么错,回去帮你看吧,还在外面

剑栈风樯各苦辛,别时冰雪到时春
2020-05-18 18:58
快速回复:求助!!ecplise中出现 Description The origin server did not find ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.043244 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved