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");
Ïà¹ØÎĵµ£º
Ê×ÏÈ£¬ËµËµ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¡ ......
Îļþ´ò¿ªÊ±ºòÊÇͨ¹ýÎļþÍ·À´È·¶¨ÎļþµÄ±àÂë
StreamReader sr=new StreamReader(@"F:\cym\temp\1.txt");
sr.CurrentEncoding //·µ»Ø±àÂë
ÊÀ½çÉϵĸ÷µØÇø¶¼Óб¾µØµÄÓïÑÔ¡£µØÇø²îÒìÖ±½Óµ¼ÖÂÁËÓïÑÔ»·¾³µÄ²îÒì¡£ÔÚ¿ª·¢Ò»¸ö¹ú¼Ê»¯³ÌÐòµÄ¹ý³ÌÖУ¬´¦ÀíÓïÑÔÎ ......
1¡¢ÈçºÎÏÔʾĿ¼ÁÐ±í£º
ÎÒÃÇÔÚ±¾»ú²âÊÔ³ÌÐòʱ£¬Ò»°ã¶¼Ï°¹ßÔÚä¯ÀÀÆ÷ÖоÍÄܱéÀúµ½Ä³¸öĿ¼Ï¶¼ÓÐÄÄЩÎļþ£¬Õâ¾ÍÐèÒªweb·þÎñÆ÷Ö§³ÖĿ¼ÁÐ±í£º
´ò¿ªÎļþconf/web.xml£¬ÕÒµ½ÒÔÏ´úÂ룺
<param-name>listings</param-name>
<param-value>false</param-value>
½«ÆäÖеÄfalse¸Ä³Étrue
2¡¢ÅäÖÃerror-p ......
JSPÓï·¨Ïê½â[תÌû]
HTML×¢ÊÍ:
1) ¿ÉÒÔÓÃ×¢ÊÍÄÚÈÝ,Ò²¿ÉÒÔÓñí´ïʽ.
2)Òþ²Ø×¢ÊÍ:
×¢Êͻᱠ......
ʹÓÃ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 ......