2014-07-24 4 views
0

사용자가 몇 개의 체크 상자를 확인하는 jsp1이 있습니다 jsp2에서 문자열을 사용하여 확인란 값을 읽을 수 있습니다.JSP - 문자열 배열을 생성자에 전달

그러나 jsp1에서 선택한 매개 변수를 사용하여 사용자 개체를 만들어야 텍스트 파일에 쓸 수 있습니다. 이것은 내가 도로 블록을 때리는 곳입니다. 독립적으로 코드를 실행하면 Java 콘솔이 제대로 작동합니다. 그러나 실제 코드는 그렇지 않습니다. 나는 생성자 공용 클래스 사용자 에 대한 오류 아래

An error occurred at line: 29 in the jsp file: /ProcessMyForm.jsp 
The constructor User(String, String, String, String, String, String[], String) is undefined 
26:   String path = sc.getRealPath("/WEB-INF/EmailList.txt"); 
27: 
28:   // use regular Java objects 
29:  User user = new User(userName, emailAddress, password, comment, emailFormat, serverScript, occupation); 
30:  UserIO.add(user, path); 
31:  %> 
32: 

아래의 코드를 내가 JSP로 값을 읽고, 오브젝트 아래

<% 
    // get parameters from the request 
    String userName = request.getParameter("userName"); 
    String emailAddress = request.getParameter("emailAddress"); 
    String password = request.getParameter("password"); 
    String comment = request.getParameter("comment"); 
    String emailFormat = request.getParameter("emailFormat"); 
    String serverScript[] = request.getParameterValues("serverScript"); 
    String occupation = request.getParameter("occupation"); 



    ServletContext sc = this.getServletContext(); 
    String path = sc.getRealPath("/WEB-INF/EmailList.txt"); 


    User user = new User(userName, emailAddress, password, comment, emailFormat, serverScript, occupation); 
    UserIO.add(user, path); 
%> 

을 만들려고 해요 코드입니다 받고 있어요 { 전용 문자열 userName; 전용 문자열 emailAddress; 전용 문자열 암호; 전용 문자열 주석. private String emailFormat; 전용 문자열 serverScript []; 개인 문자열 직업;

@SuppressWarnings("empty-statement") 
public User() 
{ 
    userName = ""; 
    password = ""; 
    emailAddress = ""; 
    comment = ""; 
    emailFormat = ""; 
    occupation = ""; 
} 

public User(String userName, String emailAddress, String password, String comment, String emailFormat, String[] serverScript, String occupation) 
{ 
this.userName = userName; 
this.emailAddress = emailAddress; 
this.password = password; 
this.comment = comment; 
this.emailFormat = emailFormat; 
this.serverScript= serverScript; 
this.occupation = occupation; 

} 

문제를 해결할 수 있도록 도와 주시겠습니까? 추가 정보가 필요하면 알려주세요.

답변

0

넷빈즈를 닫았을 때 열었습니다. 교수님은 때로는 업데이트 된 클래스가 서버에 의해 선택되지 않는다고 말했습니다.

관련 문제