首页 > 代码库 > 蜗牛—JSP学习之JavaBean初识

蜗牛—JSP学习之JavaBean初识

初识:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href=http://www.mamicode.com/"">>


通过HTTP表单中的參数设置JavaBean的属性值

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href=http://www.mamicode.com/"">>

有可能在填入中文的时候输出会乱码

能够在.java文件里编写代码

public String getPassword() {
		try {
			byte b[] = password.getBytes("ISO-8859-1");
			password = new String(b, "UTF-8");
			return password;
		} catch (Exception e) {
			// TODO: handle exception
			return password;
		}
	}