0
我有jsp1,其中用戶選中幾個複選框 在jsp2上,我成功地使用String讀取了複選框值。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);
%>
下面的代碼的代碼構造 公共類用戶 私人字符串用戶名; private String emailAddress; 私人字符串密碼; 私人字符串評論; private String emailFormat; private String 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;
}
請您幫我解決問題。請讓我知道,如果你需要更多的細節