JSP·ÖÒ³Ö®¼Ù·ÖÒ³¼°MVCʵÏÖ
MVCÊÇÓÉÄ£ÐͲ㣬ÊÓͼ²ã£¬¿ØÖƲã×é³É£¬MVCÌá¸ßÁË¿ª·¢Ð§ÂÊ£¬±ãÓÚά»¤
·ÖÒ³ÊÇWeb¿ª·¢ÖеÄÒ»¸öÖØÒªµÄ¹¦ÄÜ£¬ÄÇÔõÑùʵÏÖ·ÖÒ³ÄØ£¿£¿£¿
¼Ù·ÖÒ³ÊÇÖ¸²éѯ³öËùÓеÄÊý¾Ý£¬Ö»ÏÔʾÐèÒªµÄÊý¾Ý£¬ËüÍêÈ«ÓɳÌÐòʵÏÖ£¬¿ª·¢Ð§Âʲ»¸ß£¬µ«ÈÝÒ×ʵÏÖ
´úÂëÈçÏÂ:
Ò».Ä£ÐͲã
UserInfo(JavaBeanµÄʵÏÖ£¬´«µÝÊý¾Ý£©
package com.feng.test;
import java.io.Serializable;
public class UserInfo implements Serializable {
private int userid;
private String username;
private String password;
public int getUserid() {
return userid;
}
public void setUserid(int userid) {
this.userid = userid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
¶þ.Êý¾Ý²ã
DataBae(Êý¾Ý¿âµÄÁ¬½Ó)
package com.feng.test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public final class DataBase {
private final static String DRIVER = "oracle.jdbc.driver.OracleDriver";
private final static String URL = "jdbc:oracle:thin:@localhost:1521:Oracle9i";
private final static String USER = "scott";
private final static String PWD = "tiger";
private DataBase() {
}
public static Connection getConnection() {
Connection conn = null;
try {
Class.forName(DRIVER);
conn = DriverManager.getConnection(URL, USER, PWD);
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}
public static void closeConnection(Connection conn) {
try {
if (conn != null) {
if (!conn.isClosed()) {
conn.close();
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public static PreparedStatement getPreparedStatement(Connection conn,
String sql) {
PreparedStatement pstmt = null;
try {
pstmt = conn.prepareStatement("sql");
Ïà¹ØÎĵµ£º
a.jspÒ³ÃæÄÚÈÝ£º
%26lt;%@ page language£½"java" import£½"java.util." pageEncoding£½"GB2312"%%26gt;%26lt;form action£½"b.jsp"%26gt; name£º%26lt;input type£½text name£½name%26gt; %26lt;input type£½submit%26gt;%26lt;/form%26gt;
b.jspÒ³ÃæÄÚÈÝ£º
%26lt;%@ page language£½"java" import£½"java.util." pageE ......
Ê×ÏÈ£¬ËµËµJSP/ServletÖеļ¸¸ö±àÂëµÄ×÷Óá£
ÔÚJSP/ServletÖÐÖ÷ÒªÓÐÒÔϼ¸¸öµØ·½¿ÉÒÔÉèÖñàÂ룬pageEncoding="UTF-8"¡¢contentType="text/html;charset=UTF-8"¡¢request.setCharacterEncoding("UTF-8")ºÍresponse.setCharacterEncoding("UTF-8")£¬ÆäÖÐÇ°Á½¸öÖ»ÄÜÓÃÓÚJSPÖУ¬¶øºóÁ½¸ö¿ÉÒÔÓÃÓÚJSPºÍServletÖС£
1¡ ......
±¾ÎÄ×÷ÕߣºØýÃû
ËùÊô·ÖÀࣺÍøÂç±à³Ì
¼ÓÈëʱ¼ä£º2006-1-19
µã»÷´ÎÊý£º396
<%@ page language="java" contentType="text/html" %>
<%@ page import="com.ora.jsp.util.*" %>
<html>
<body bgcolor="white">
<form action="checkbox.jsp">
<input type="checkbox" name="fr ......
ʹÓÃjspf
ÔÚ¿ª·¢ÖÐдjspÒ³Ãæʱ£¬Í¨³£¶¼ÒªÍ¨¹ýÈçÏ·½Ê½ÔÚjspÎļþÍ·²¿ÒýÈëÎÒÃÇÐèÒªµÄ±êÇ©¿â£¬È磺jspºËÐıêÇ©¿âJSTL£¬Struts ÖеÄ×Ô¶¨Òå±êÇ©£¬Ê±¶ø»¹ÓÐÎÒÃÇ×Ô¼ºÐ´µÄ×Ô¶¨Òå±êÇ©£º
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefi ......