jsp²åͼƬµ½MySQL - Web ¿ª·¢ / ÆäËû
¸ãÁËÒ»¸öÏÂÎçÁË£¬ËÑË÷ÁËÍøÂ绹Êǽâ¾ö²»ÁË...Ï£Íû¸ßÊÖ°ïæ½â¾öÏÂ
Ô´´úÂ룺
private void SendPhoto(HttpServletRequest request,
HttpServletResponse response) {
String name=request.getParameter("image"); //»ñȡͼƬ·¾¶£¬²âÊÔºóûÓÐÎÊÌâ
String filename=name.replace("\\", "\\\\");
File file=new File(filename);
InputStream str = null;
try {
str = new BufferedInputStream(new FileInputStream(file));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
String sql= "insert into photos(image) values(null,now(),?)";//null¶ÔÓ¦µÄΪ×Ô¶¯Ôö¼ÓµÄid,imageµÄÀàÐÍΪblob
Connection conn=DB.getConn();//DBÊÇ·â×°µÄÁ´½ÓÊý¾Ý¿âµÄÀà
PreparedStatement pstmt=DB.prepareStmt(conn, sql);
try {
pstmt.setBinaryStream(1,str,str.available());
result=pstmt.executeUpdate();
pstmt.close();
str.close();
} catch (SQLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
´íÎóÈçÏ£ºcom.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?:?v·é-??±???ü??zq?5*?we,V·Zd?I?ùQ??ü] ???
z???#?o>?l6? (??Rz?*?o??§???Wu??¡
Ïà¹ØÎÊ´ð£º
ÎÒÒѾ°´Õս̳ÌÉÏÅäÖÃtomcatµÄserver.xml
<Context path = "/POS" docBase = "POS" debug = "5" reloadable = "true" crossContext = "true" workDir = &quo ......
ÎÒÊǸöÐÂÊÖ£¬×öÒ»¸öJSPÍøÒ³£¬ÎÒÒª¶Á³öÊý¾Ý¿âÕý³££¬µ«ÊÇÎÒÒªÐ޸ĵÄʱºò£¬Ò²¾ÍÊǶÁÈëµÄʱºò³öÏÖÂÒÂ룬Çë¸ßÊÖ¸æËßÎÒÔõô½â¾ö£¬ÏÈллÁË¡£
request.setCharacterEncoding("UTF-8");
°Ñ±àÂëͳһ
/**
......
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 52 in the jsp file: /vip_info.jsp
ÕË cannot be resolved
49: <table border="1& ......
ÎÒÔÚjspÒ³ÃæÀïÓÐÒ»¸öÏÂÀÁÐ±í£¬ÀïÃæÓÐÁ½¸öÖµ·Ö±ðÊǹ̶¨×ʲú¡¢ÆäËû×ʲú£¬´úÂëÈçÏ£º
<select name="select">
<option value="¹Ì¶¨×ʲú">¹Ì¶¨×ʲú</option>
<option ......
±ÈÈç˵DB.classÊÇÔÚ°ücom/zhl/jdbcϵÄ
ÄÇôDB.class·ÅÔÚʲôµØ·½ Èç¹ûÓÃ<jsp:useBean id="d" class=""/>À´ÒýÈëbean ÄÇôclassÊôÐÔÓ¦¸ÃÔõôд
Ðè²»ÐèÒªÏñservletÄÇÑù»¹ÒªÅäÖÃweb.xmlµÄ& ......