在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!