javabean:
package com.baozi;
import java.io.Serializable;
public class Questionnaire implements Serializable{
private static final long serialVersionUID = 1L;
private String[] language;
private String[] technic;
private String[] difficulty;
public String[] getLanguage() {
return language;
}
public void setLanguage(String[] language) {
this.language = language;
}
public String[] getTechnic() {
return technic;
}
public void setTechnic(String[] technic) {
this.technic = technic;
}
public String[] getDifficulty() {
return difficulty;
}
public void setDifficulty(String[] difficulty) {
this.difficulty = difficulty;
}
}
convert:
package com.baozi;
public class Convert {
public String arr2Str(String [] arr){
StringBuffer sb=new StringBuffer();
if(arr!=null&&arr.length>0)
for(String s:arr){
sb.append(s);
sb.append(' ');
}
return sb.toString();
}
}
index.jsp
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312" isErrorPage="true"%>
<%request.setCharacterEncoding("gb2312"); %>
<%@page import="com.baozi.*" %>
<!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=gb2312">
<title>问卷调查</title>
</head>
<body>
<form action="result.jsp" method="post">
<h1>问卷调查</h1>
<hr>
<ul>
<li>您经常使用的程序设计语言:</li>
<li>
<input type="checkbox" name="language" value="JAVA">JAVA
<input type="checkbox" name="language" value="C++">C++
<input type="checkbox" name="language" value=".NET">.NET
<input type="checkbox" name="language" value="PYTHON">PYTHON
</li>
</ul>
<ul>
<li>您目前掌握的技术:</li>
<li>
<input type="checkbox" name="technic" value="HTML">HTML
<input type="checkbox" name="technic" value="JSP">JSP
<input type="checkbox" name="technic" value="JAVABEAN">JAVABEAN
<input type="checkbox" name="technic" value="SERVLET">SERVLET
</li>
</ul>
<ul>
<li>在学习中哪一部分感觉有困难:</li>
<li>
<input type="checkbox" name="difficulty" value="STUTS2">STUTS2
<input type="checkbox" name="difficulty" value="SPRINGMVC">SPRINGMVC
<input type="checkbox" name="difficulty" value="HIBERNATE">HIBERNATE
<input type="checkbox" name="difficulty" value="AJAX">AJAX
</li>
</ul>
<input type="submit" value="提 交">
</form>
</body>
</html>
result.jsp
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<%request.setCharacterEncoding("gb2312"); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.baozi.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>问卷结果</title>
</head>
<body>
<jsp:useBean id="questionnaire" class="com.baozi.Questionnaire"></jsp:useBean>
<jsp:useBean id="convert" class="com.baozi.Convert"></jsp:useBean>
<jsp:setProperty name="questionnaire" property="*"/>
<h1>问卷结果</h1>
<hr>
<ul>
<li>您经常使用的程序设计语言:<%=convert.arr2Str(questionnaire.getLanguage())%></li>
<li>您目前掌握的技术:<%=convert.arr2Str(questionnaire.getTechnic()) %></li>
<li>在学习中哪一部分感觉有困难:<%=convert.arr2Str(questionnaire.getDifficulty()) %></li>
</ul>
</body>
</html>
image.png
image.png
网友评论