Q
qukmei
Unregistered / Unconfirmed
GUEST, unregistred user!
我用jb9的向导建立了一个javaBean
package servlet;
import java.io.*;
public class UserBean implements Serializable {
private String username;
public UserBean() {
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject();
}
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject();
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
编译通过,我用一个1.jsp来做表单,2.jsp做为userbean的jsp,这样1.jsp输入东西,提交2.jsp就可以显示,英文显示没有问题,中文就是乱码,不知道怎么处理。
2.jsp
<%@ page contentType="text/html;
charset=gb2312" %>
<html>
<head>
<title>
userbean
</title>
</head>
<jsp:useBean id="mybean" scope="session" class="servlet.UserBean" />
<jsp:setProperty name="mybean" property="*" />
<body bgcolor="#ffffff">
<h1>
JBuilder Generated JSP
</h1>
<jsp:getProperty name="mybean" property="username"/>
</body>
</html>
package servlet;
import java.io.*;
public class UserBean implements Serializable {
private String username;
public UserBean() {
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject();
}
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject();
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
编译通过,我用一个1.jsp来做表单,2.jsp做为userbean的jsp,这样1.jsp输入东西,提交2.jsp就可以显示,英文显示没有问题,中文就是乱码,不知道怎么处理。
2.jsp
<%@ page contentType="text/html;
charset=gb2312" %>
<html>
<head>
<title>
userbean
</title>
</head>
<jsp:useBean id="mybean" scope="session" class="servlet.UserBean" />
<jsp:setProperty name="mybean" property="*" />
<body bgcolor="#ffffff">
<h1>
JBuilder Generated JSP
</h1>
<jsp:getProperty name="mybean" property="username"/>
</body>
</html>