웹 양식에서 사용한 여러 레이블의 값을 가져오고 싶습니다. 숨겨진 된 입력 필드를 사용하여이 일을 얻을 수 있지만 레이블 값으로 null 점점 Im 같이 서블릿을 통해 레이블 값을 인쇄 할 수 없습니다.서블릿에서 레이블 값을 인쇄 할 수 없습니다.
다음 샘플 코드는 사용하고 있습니다 테스트
index.jsp를
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form name = "testform" action="submit" method = "post">
<label> AgeoftheChild </label>
<input type="hidden" name="lblage" value="AgeoftheChild">
<input type = "radio" name="age" value="10">10 <br>
<input type = "radio" name="age" value="20">20 <br>
<input type = "radio" name="age" value="30">30 <br>
<input type="submit" name="sub" value="submit">
</form>
</body>
이것은 submit.java 서블릿
public class submit extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String age = request.getParameter("lblAge");
try {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet NewServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet NewServlet at " + age + "</h1>");
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
}
에게 있습니다
}
내가 AgeoftheChild 를 표시하고자하지만 출력이
는lblage
과에 전달하는 HTML 페이지에서 사전
에서 편집되었습니다. D : 많이 고마워요! – userSu