양식이 가득한 JSP 페이지가 있습니다. 제출을 클릭하면 getParamValues 메소드를 사용하여 측량의 양식 값을 읽는 것으로 가정되는 서블릿으로 이동하지만 작동하지 않습니다. getParamValues에서 String 배열을 인쇄하려고하면 nullpointerexceptions이 계속 발생합니다. 여기 JSP에서 양식 값을 읽을 수 없습니다.
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
resp.setContentType("text/plain");
PrintWriter out = resp.getWriter();
String[] nums = req.getParameterValues("questNum");
out.println(nums[2]);
}
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
doPost(req, resp);
}
가 GAE에서 실행, 관련 JSP 코드 : 여기
는 관련 서블릿 코드까지 주어진 정보, a의 유일한 원인을 바탕으로
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="com.surveycreator.service.persistence.SurveyPersistence" %>
<%@ page import="com.surveycreator.service.model.Survey" %>
<%@ page import="com.surveycreator.service.model.SurveyQuestion" %>
<%@ page import="com.surveycreator.service.model.Survey" %>
<%@ page import="java.util.List" %>
<html>
<head>
<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
</head>
<body>
<p>View Survey</p>
<form action="/storesurvey" method="post">
<input type="submit" value="Submit Survey" />
</form>
<%
SurveyPersistence persist = new SurveyPersistence();
String surveyName = request.getParameter("content");
Survey survey = persist.getSurvey(surveyName);
List<SurveyQuestion> question = survey.getSurvey();
out.println("<table border='1'><tr><th>QuestionNumber</th><th>Survey Question</th><th>(Yes/yes)(No/no)</th></tr>");
for (SurveyQuestion questionObject : question) {
int tableCounterString = questionObject.getQuestionNumber();
String quest = questionObject.getQuestion();
out.println("<tr><td><form><input id ='question' name='questNum' type='text' readonly='readonly' value='"+tableCounterString + " ' /></form></td><td><form><input id ='question' name='quest' type='text' readonly='readonly' value='"+quest + " ' /></form></td><td><form><input id ='ans' name='answer' type='text' value='' /></form></td></tr>");
}
%>
<%= survey.getSurveyName()%>
</body>
</html>
이 링크는 HTTP 500 오류 페이지로 연결되며 특히 도움이되지 않습니다. 관련 소스 코드를 게시하십시오. – BalusC
jsp 코드를 게시 할 수 있습니까? – Lalchand