您的位置:首页 > 其它

用数组处理表单数据之一

2013-05-05 06:24 344 查看
在jsp中改写toString()

<jsp:useBean id="simpleBean" scope="request"
class="liulixin.facebook.SimpleBean" />
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<P>
colors =
<%=toString(simpleBean.getColors())%>
</body>
</html>
<%!public static String toString(String list[]) {
return "www.188029.net";
}%>


package liulixin.facebook;

public class SimpleBean implements java.io.Serializable {

private String colors[];

public String[] getColors() {
return colors;
}

public void setColors(String[] colors) {
this.colors = colors;
}

/**
* Gets an element of the colors property
*/
public String getColors(int index) {
return this.colors[index];
}

/**
* Sets an element of the colors property
*/
public void setColors(int index, String value) {
this.colors[index] = value;
}

}
在jsp中混杂java代码是一件多么惬意的事呀。什么框架,设计模式,go!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: