2012-07-01 1 views
0

이전 게시물 here에 이어 모든 소스 파일을 model 패키지로 제거 했으므로 http://localhost:8080/MyFirstServlet을 실행하는 동안 프로젝트로드가 거부됩니다.간단한 JSP 파일을 열려고하면 HTTP 상태 500이 생성됩니다.

의 web.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/javaee" 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" id="WebApp_ID" version="2.5"> 
    <display-name>MyFirstServlet</display-name> 
    <welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
    </welcome-file-list> 

    <servlet> 
    <description></description> 
    <display-name>LoginServlet</display-name> 
    <servlet-name>LoginServlet</servlet-name> 
    <servlet-class>model.LoginServlet</servlet-class> 
</servlet> 


    <servlet-mapping> 
    <servlet-name>LoginServlet</servlet-name> 
    <url-pattern>/model/LoginServlet</url-pattern> 
    </servlet-mapping> 
</web-app> 

    [1]: https://stackoverflow.com/questions/11282231/jsp-page-wont-move-the-another-page-after-user-enters-the-input/11283006#11283006 

이 index.jsp가가가 :

<%@ page language="java" contentType="text/html; charset=windows-1255" 
    pageEncoding="windows-1255"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255"> 
<title>Insert title here</title> 
</head> 
<body> 
<form action="model/LoginServlet" method="POST"> 
     First Name: <input type="text" name="firstName" size="20"><br> 
     Last Name: <input type="text" name="lastName" size="20"> 
     <br><br> 
     <input type="submit" value="Submit"> 
</form> 

</body> 
</html> 

이것은이다

여기 파일입니다, 범인 web.xml 의심 프로젝트 계층 구조 :

,

hierarchy

나는 http://localhost:8080/MyFirstServlet를 실행하고 여기에 도달하면 : 텍스트 필드에

enter image description here

내가 first 입력

second을 다음이 얻을 : 나는했습니다

enter image description here

을 그것을 고치려고했지만 아무 것도하지 않았다. 그래서 어떤 충고도 고맙게 생각한다. :)

답변

1

해야한다.

package model; 

또한 당신의 web.xml은

model.LoginServlet 

당신의 서블릿의 HttpServlet를 확장해야 완전한 이름을 통해이 서블릿 클래스를 선언해야합니다.

위의 모든 것이 올 바르고 올바르게 작동하는지 확인하는 경우에도 마찬가지입니다. 그런 다음이 프로젝트의 빌드 경로 설정을 Eclipse에서 확인해야합니다.

1
<servlet> 
    <description></description> 
    <display-name>LoginServlet</display-name> 
    <servlet-name>LoginServlet</servlet-name> 
    <servlet-class>model.LoginServlet</servlet-class> 
</servlet> 

서블릿 클래스 용 패키지가 누락되었습니다.

+0

여전히 작동하지 않습니다. 다른 아이디어가 있습니까? thanks – ron

+0

그래도 작동하지 않는다면 새로운 스택 추적이 있어야합니다. 그렇지 않으면 새 web.xml이 제대로 배포되지 않고 여전히 이전 web.xml이 참조됩니다. –

0

stacktrace가 오류를 명확하게 보여 주며, ClassNotFoundException은 서블릿 컨테이너가 web.xml에서 지정된 클래스를 찾을 수 없음을 의미합니다.

+0

나는 그것을 볼 수는 있지만 어떻게 수정해야합니까? – ron

+0

서블릿을 정리하고 경고/불필요한 참조 패키지를 제거한 다음 tomcat을 중지하고 서버를 배포 한 다음 다시 시작하여 모든 것을 다시 배포하십시오. 아직도 작동하지 않으면 알려주세요. – amitprot

0

LoginServlet.java 코드의 첫 번째 줄은 당신이 작업을

<form action="model/LoginServlet" /> 

하고 로그인 서블릿이 제대로 패키지를 정의해야해야한다 형성

package model; 
+0

나는 이미 그것을 썼다. 도움이되지 않았다. 10x – ron

+0

action = "model/LoginServlet"대신 action = "/ model/LoginServlet"을 사용하십시오. – rickz

+0

나는 도움이되지 않았습니다. – ron