StringUtil5.java
public class StringUtil5 {
private int[] intArr;
private String str="";
public StringUtil5(){}
public int[] getIntArr() {
return intArr;
}
public void setIntArr(int[] intArr) {
this.intArr = intArr;
}
public String getStr() {
for(int i=0;i<intArr.length;i++){
str+=String.valueOf(intArr[i]);
if(i<intArr.length-1){//数组元素转为字符串并拼接
str+=",";
}
}
return str;
}
public void setStr(String str) {
this.str = str;
}
}
index.jsp
<body>
<%
int month[] = new int[12];
for(int i=0;i<month.length;i++){
month[i]=i+1;
}
%>
<jsp:useBean id="strBean" class="com.count.StringUtil5"></jsp:useBean>
<jsp:setProperty property="intArr" name="strBean" value="<%=month %>"/>
<table width="220">
<tr bgcolor="skyblue">
<td align="center">一年中的月份:</td></tr>
<tr>
<td align="center">
<h4><jsp:getProperty property="str" name="strBean"/></h4>
</td></tr>
</table>
</body>