天天看點

J2EE/J2SE 錯誤記錄

07骞?2鏈?8鍙?1锛氫嬌鐢╦spSmartUpload缁勪歡鏃跺嚭鐜頒笉鑳戒笅杞界殑寮傚父锛屽悗鏉ュ彂鐜扮粍浠舵湁闂锛?鍦╩ySmartUpload.initialize(pageContext);涓€鍙ュ墠浜嗗姞涓?out.clear();聽聽聽聽

out=pageContext.pushBody(); 鍚庤В鍐?2锛氫嬌鐢╦spSmartUpload缁勪歡鏃跺嚭鐜頒笉鑳芥樉绀虹殑寮傚父

鍚庡彂鐜拌皟鐢ㄦ柟娉曞繀椤諱負鈥減ost鈥濓紱<form action="sample1.jsp" enctype="multipart/form-data" method="post">

07骞?2鏈?9鍙鳳細

eclipse 鍦?new Servlet鐨勬椂鍊欏嚭鐜扮増鏈彿鐨勫紓甯革紝鍦╡clipse涓瘯鐫€淇敼JDK鍚庤繕鏄笉琛?鏈€鍚庡彂鐜頒笉鐜鍙橀噺鐨勮礬寰勬湁闂锛屾敼杩囧悗 閲嶅惎eclipse鍚庢甯搞€?

07骞?2鏈?0鍙?1:鍦ㄧ敤commons fileUpload缁勪歡鏃訛紝鍑虹幇java.io.FileNotFoundException: F:/upLoaded (鎷掔粷璁塊棶銆?鐨勯敊璇?鍚庡彂鐜闆鏋滀笂浼犱負绌烘椂锛宖ileName涓嶄負null锛岃€屾槸涓?";淇敼鍚庤В鍐?

2:鍙戠幇鍦╟ommons fileUpload鍜宩spSmartUpload涓笂浼犳枃浠訛紝鏂囦歡鍚嶄負涔辯爜鐨勯棶棰橈紝

鍚庡湪涓婁紶鏂囦歡鐨刯sp涓婂姞鍏?lt;%@ page language="java" contentType="text/html; charset=gbk"

聽聽聽 pageEncoding="gbk"%>闂瑙e喅

07骞?2鏈?0鍙?浠婂ぉ鍦ㄧ敤jdbc璁塊棶mysql鏃跺彂鐜拌€佸嚭鐜伴敊璇繛涓嶄笂鏁版嵁搴擄紝寮€濮嬩互涓烘槸鏁版嵁閲忚繃澶э紝鍚庢潵鍙戠幇鏄洜涓?閰嶇疆鏂囦歡涓殑url鏄敤浠ュ墠鐨勬病鏈夌鍙e彿鐨勯偅涓紝鍚庢潵鏀逛負jdbc.url=jdbc:mysql://localhost:3309/edulocal,闂瑙e喅.

07骞?2鏈?7鍙?浠婂ぉ鍙堥亣鍒頒簡Apache Tomcat 鍚姩涓嶄簡鐨勯棶棰?鍦╡clipse涓嬭兘鎵撳紑锛屽叾浠栨儏鍐典笅鍗存墦涓嶅紑锛岀棁鐘舵槸start涔嬪悗闂簡涓€涓嬶紝鐒跺悗鍚姩鐣岄潰灏辨秷澶變簡,鑰孴omcat 杩樻槸娌℃湁鍚姩.

聽聽聽聽聽聽 鎴戝湪Apache Tomcat 鐨勫畨瑁呯洰褰曚笅鎵撳紑logs鏂囦歡澶?鎵懼埌浠婂ぉ鐨勬棩蹇楄繘琛屽垎鏋愬悗鍙戠幇閿欒鍘熷洜鏄壘涓嶅埌涓€涓ā鍧?

[2007-09-11 22:40:35] [174 javajni.c] [error] 鎵句笉鍒版寚瀹氱殑妯″潡銆?

浜庢槸鎴戞妸jre閲岀殑msvcr71.dll鏂囦歡鎷瘋礉鍒癈:/windows/system32涓嬮潰,閲嶆柊鍚姩Tomcat 鍚?闂瑙e喅浜?

2锛氬厤瀹夎鐗堢殑Tomcat6鍚姩涓嶄簡鏈嶅姟

聽聽 鍚庡湪

聽聽 C:/songguanghui/tomcat6/bin鐩綍涓媍atalina.bat,service.bat,startup.bat涓?聽聽 rem ---------------------------------------------------------------------------

聽聽 鍚庡姞涓?聽聽 set JAVA_HOME=C:/songguanghui/Java/jdk1.6.0

聽聽 set CATALINA_HOME=C:/songguanghui/Tomcat6

聽聽 瑙e喅!

鎷瘋礉jdk鍒皌omcat瀹夎鐩綍锛屼笉蹇呭啀閰嶇疆tomcat鐨刯dk璺緞

鎷瘋礉jdk瀹夎鐩綍涓嬬殑 bin銆乮nclude鍜宭ib鐩綍鎷瘋礉鍒皌omcat鐨勫畨瑁呯洰褰曚笅銆備笖jdk鐩綍鍚嶏細jdk1.6.0_01

鐒跺悗淇敼startup.bat鏂囦歡锛屽湪鏂囦歡澶撮儴鍔犲涓嬩唬鐮侊細

set CURRENT_DIR=%cd%

cd ..

set CURRENT_DIR=%cd%

set JDK_HOME=%CURRENT_DIR%

set JAVA_HOME=%JDK_HOME%/jdk1.6.0_01

set CURRENT_DIR=%cd%

cd %CURRENT_DIR%/bin

鍗沖彲銆?

2008骞?鏈?鍙?Web宸ョ▼涓媁EB-INF涓璍ib涓姞鍏ar鍖呭悗锛屼笉鑳借嚜鍔ㄥ鍏ュ埌Web App Libraries涓€?鍚庡湪宸ョ▼buiderPath->addLibraries->Web App Libraries->宸ョ▼鍚?>纭畾

瑙e喅锛?servlet涓嬌鐢╦avaScript锛?post涓?聽聽 response.setContentType("text/html;charset=GBK");

聽聽 PrintWriter out = response.getWriter();

聽聽 --------------------------------------------------------------

聽聽 out.print("<script>alert('娉ㄥ唽浜烘暟宸叉弧,娣誨姞鐢ㄦ埛澶辮觸锛?);</script>");

聽聽 out.print("<script>location.href='/xtgl/admu_adduser.jsp';</script>");

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 out.print("<script>top.location.href='/xtgl/admu_adduser.jsp';</script>");杩炴帴鍒版渶涓婂眰

聽聽 out.print("<script>window.close();</script>");

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <a href="Javascript:window.history.go(-1)" target="_blank" rel="external nofollow" >

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 慰nclick="javascript:window.close();

Response.write聽聽 " <script >alert( &apos;鏍¢獙涓嶆纭紒 &apos;);javascript:history.back(); </script >

out.print("<script>window.open('grxxNum33.jsp', 'newwindow', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')</script>");

聽聽

2008骞?鏈?0鍙?鍙戠幇Tomcat涓嶆墽琛屾柊鏀瑰悗鐨刯sp鏂囦歡锛屽彧鎵ц浠ュ墠鐨勩€傘€傘€?鍚庡湪C:/huayangedu/Tomcat5/work/Catalina/localhost/_/org/apache/jsp

涓嬫壘鍒癹sp缂栬瘧杩囩殑servlet鎶婂叾鍒犻櫎鍚庛€傚氨鍙互浜?

2008骞?鏈?鏃?Hibernate+Spring 鏌ユ暟鎹簱鏃跺嚭鐜?could not initialize proxy - no Session

閿欒锛屽悗淇敼

聽聽 <many-to-one name="ygbm" class="Bmxx" lazy="false">

聽聽聽 <column name="bmid"></column>

聽聽 </many-to-one>

lazy璁句負false鍚庤В鍐?

2008骞?鏈?鏃?org.apache.jasper.JasperException: Unable to compile class for JSP 瑙e喅鏂規硶

鎶妀dk瀹夎鐩綍涓嬬殑lib/tools.jar鎷瘋礉鍒皌omcat瀹夎鐩綍涓嬬殑common/lib鐩綍涓嬶紝鐒跺悗閲嶅惎tomcat锛?

2008骞?鏈?鏃?javascrip鍜屽嚱鏁頒紶瀛楃涓插弬鏁幫紝璋冪敤鏃跺簲鍔犫€溾€?鈥欌€濆崟寮曞彿

2008骞?鏈?0鏃?Eclipse鐢熸垚鐨剋eb.xml鐨?lt;web-app></web-app>涓坊鍔?lt; taglib>鏍囩鍑洪敊,

鎴恮eb宸ョ▼鏃訛紝浜х敓鐨剋eb.xml鏂囦歡涓殑<web-app>鏍囩鏄繖鏍風殑锛?<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

鑰屼笉鏄細

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">

<web-app>

......

</web-app>

搴旇鏄笌xml schema鏈夊叧銆?

姝g‘鏂規硶搴旇鏄敤<jsp-config></jsp-config>鎶妕iglib鍖呭惈璧鋒潵鍗沖彲浠ユ帓闄ら敊璇€傛澶栵紝鏈変簺 web.xml鐨勫彲瑙嗗寲缂栬緫涓嶅姞<jsp-config>鐨勮瘽璁や笉鍑簍aglib鐨勫唴瀹廣€?

2008骞?鏈?1鍙?hibernate+String涓€佹姤could not initialize a collection: 閿欒锛屽悗鍙戠幇涓€瀵瑰鍏崇郴鏃訛紝濡傛灉鏈変袱涓竴瀵瑰鐨勫叧绯夥紝瑕乴azy=鈥渢rue鈥?

2008骞?鏈?4鏃?jsp浼犲埌servlet涓唬鐮佸叏鏄貢鐮佲€濓紵锛燂紵锛熲€滐紝鍚庡彂鐜版槸瀛楃杞崲鐨勯棶棰?鍐欎簡涓€涓皬鏂規硶锛屾妸鎵€鏈夌殑String杞崲涓€涓嬶紝灏卞ソ浜?鏂規硶濡備笅:

public String toGbk(String x) {

聽聽 byte[] y;

聽聽 try {

聽聽聽 y = x.getBytes("ISO8859_1");

聽聽聽 String z = new String(y, "gbk");

聽聽聽 return z;

聽聽 } catch (UnsupportedEncodingException e) {

聽聽聽 e.printStackTrace();

聽聽聽 return "zhi fu ji cuowu!";

聽聽 }

}

2008骞?鏈?8鍙?jsp涓敤javascript鏃ュ巻涓殑鏃堕棿鏍煎紡鍜屽浗闄呭寲鏍囩鐨勬椂闂存牸寮忎笉涓€鏍鳳紝鍚庢潵鍙戠幇鏈堜喚鏄竴浣嶆垨涓や綅锛屾爣绛句腑鐨勬湀浠介粯璁や負浣?鍚庡姞涓€涓柟娉曡В鍐籌紒

濡備笅锛?public static String getNowDateShort() {

聽聽聽聽聽 Date currentTime = new Date();

聽聽聽聽聽 SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

聽聽聽聽聽 String dateString = formatter.format(currentTime);

聽聽聽聽聽 return dateString;

}

servlet涓敓鎴?浣岻nteger绫誨瀷鐨勭紪鍙風殑鏂規硶锛?public Integer getId(){

聽聽 Date id=new Date();

聽聽聽聽聽聽聽 String ids=String.valueOf(id.getTime());

聽聽聽聽聽聽聽 String ids2=ids.substring(0, 9);

聽聽聽聽聽聽聽 Integer thisid=Integer.valueOf(ids2.trim());

聽聽聽聽聽聽聽 return thisid;

}

2008骞?鏈?9鍙?Tomcat璁劇疆鎶涘嚭寮傚父鏃跺簲璇ユ樉绀虹殑椤甸潰

<error-page>

<error-code>404</error-code>

<location>/notFileFound.jsp</location>

</error-page>

<error-page>

<exception-type>java.lang.NullPointerException</exception-type>

<location>/null.jsp</location>

</error-page>

<%@ page isErrorPage="true" errorPage="error.jsp"%>

聽聽聽 涔熷彲浠ユ崟鎹塏ullPointerException杩欑寮傚父,姝ゆ椂杞悜error.jsp

jsp涓<error-page> 鏃舵樉绀轟笉鍑烘潵锛屽悗鍙戠幇鏄痡sp閿欒椤甸潰澶皬浜嗭紝鍚庡湪椤甸噷闈㈠姞鍏ュぇ绾?0琛?娉ㄩ噴鍚庯紝灏辮В鍐熾€傘€?

org.apache.jasper.JasperException: 銆傘€傘€?equal symbol expected寮傚父

鏄洜涓簀sp椤甸潰鏈€涓婅竟<%@ page language="java" contentType="text/html; charset=gbk"

聽聽聽 pageEncoding="gbk"%>閿欒锛侊紒

2008骞?鏈?1鍙?浣跨敤commons鐨刦ileupload缁勪歡涓婁紶鏃訛紝鍦╯ervelt涓笉鑳戒嬌鐢?request.getParameter("")鏂規硶

鍚庡彂鐜闆湪鍥犱負鍦╦sp涓涓婁紶锛岄渶鐢ㄥ埌<form action="NwgjNum4.go" enctype="multipart/form-data" method="post">

鎵€浠ヤ笉鑳界敤

鍚庢潵鍦╯ervlet涓敤

聽聽聽聽 FileItem fi = (FileItem) object;

聽聽聽聽 String fileName=fi.getName();

聽聽聽聽 String fileName2 = fi.getFieldName();

聽聽聽聽聽聽 if(fileName2.equals("fileName")){

聽聽聽聽聽聽 fileNames=toGbk(fi.getString());

聽聽聽聽聽聽 }

聽聽聽聽聽聽 if(fileName2.equals("fileType"))

聽聽聽聽聽聽 fileType=toGbk(fi.getString());

聽聽聽聽聽聽 if(fileName2.equals("fileExp"))

聽聽聽聽聽聽 fileExp=toGbk(fi.getString());

鐨勫姙娉曡В鍐籌紒锛?

鍦╯ervlet涓嬌鐢╯pring涓環ibernate鐨刪ql璇㈢殑鏂規硶锛堢壒鍒湁鐢級锛?

聽聽 ApplicationContext app = new ClassPathXmlApplicationContext(

聽聽 "Application.xml");

聽聽聽聽聽聽聽聽 SessionFactory sessionFactory = (SessionFactory) app.getBean("huayangSessionFactory");

聽聽聽聽聽聽聽聽 Session hsession=sessionFactory.openSession();

聽聽聽聽聽聽聽聽 hsession.beginTransaction();

聽聽聽聽聽聽 int pageNumber =1;

聽聽聽聽聽聽 int pageSize=15;

聽聽聽聽聽聽 String hql="from Xzzl x order by x.zldownnum desc";

聽聽聽聽 Query query=hsession.createQuery(hql);

聽聽聽聽 query.setFirstResult((pageNumber - 1) * pageSize);

聽聽聽聽 query.setMaxResults(pageSize);

聽聽聽聽 List list=query.list();

聽聽聽 request.setAttribute("list", list);

2008骞?鏈?4鍙?java Applet灏忕▼搴忥紝缂栬瘧鍚庣殑.class鏂囦歡蹇呴』鍜屽拰jsp鏂囦歡鏀懼埌鍚屼竴璺緞涓嬶紒锛侊紒

2008骞?鏈?5鍙?eclipse鍚姩鏃舵姤

Resource is out of sync with the file system: ...閿欒銆?鍙沖嚮椤圭洰 refresh涓€涓嬪氨OK浜?杩欐槸鍥犱負鍦╡clipse澶栭儴瀵規枃浠惰繘琛屼簡淇敼閫犳垚涓嶅悓姝ョ殑闂

2008骞?鏈?鍙?鍦╰omcat鍚姩鐨勬椂鍊欙紝鍑虹幇杩欎釜璀﹀憡锛?

log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).

log4j:WARN Please initialize the log4j system properly.

瑙e喅鏂規硶锛氭妸log4j.properties鏂囦歡鎷瘋礉鍒皐eb宸ョ▼src鐩綍涓?

2008骞?鏈?鍙?jsp椤甸潰EL+jstl瀹炵幇for寰幆

聽聽聽聽聽聽聽聽聽聽聽聽聽 <c:set var="x" value="1" scope="page"/>

聽聽聽聽聽聽 <c:forEach items="${requestScope.khmx}" var="khmx">

聽聽聽聽聽 <tr>

聽聽聽聽聽聽聽 <input name="mx${x}" type="hidden" value="${khmx.mxid}"/>

聽聽聽聽聽聽聽 <td align="left">${khmx.gznr}</td>

聽聽聽聽聽聽聽 <td align="left">${khmx.gzqz}</td>

聽聽聽聽聽聽聽 <td align="left"><select name="select${x}" size="1">

聽聽聽聽聽聽聽聽聽 <option value="1.1">A</option>

聽聽聽聽聽聽聽聽聽 <option value="1.0">B</option>

聽聽聽聽聽聽聽聽聽 <option value="0.9">C</option>

聽聽聽聽聽聽聽聽聽 <option value="0.8">D</option>

聽聽聽聽聽聽聽聽聽 <option value="0.7">E</option>

聽聽聽聽聽聽聽 </select></td>

聽聽聽聽聽聽聽聽聽聽聽聽 <c:set var="x" value="${x+1}" scope="page"/>

聽聽聽聽聽 </tr>

聽聽聽聽聽聽聽 </c:forEach>

2008骞?鏈?6鍙?jsp涓垽鏂槸闆嗗悎鏄惁涓虹┖

<tr><c:choose><c:when test="${fn:length(requestScope.customers) == 0}">聽聽聽

<td>娌℃湁婊¤凍鏉′歡鐨勭邯褰?lt;/td></c:when>

<c:otherwise>聽聽

<td align="right">鍏?{fn:length(requestScope.customers)}琛?&nbsp;&nbsp;&nbsp;绗?${param.pageNumber } {requestScope.customers[0].totalPageCount } 椤?lt;/td>

</c:otherwise></c:choose></tr>

2008骞?鏈?1鏃?鍚姩eclipse鏃跺嚭鐜皉esource is out of sync with the file system

鏌ラ槄璧勬枡鍚庡彂鐜拌繖鏄枃浠剁郴缁熶笉鍚屾鐨勯棶棰橈紝鏄洜涓哄湪eclipse涔嬪瀵瑰伐绋嬩腑鐨剅esource杩涜淇敼寮曡搗鐨勶紱浣嗘槸锛屾湁鏃舵病鏈夊湪eclipse涔嬪杩涜淇敼锛屼篃浼氭姤绫諱技鐨勯敊璇€?瑙e喅鍔炴硶锛氶渶瑕佹墜鍔ㄥ埛鏂頒竴涓嬭祫婧愮鐞嗗櫒銆?锛?锛夊湪eclipse涓紝宸ョ▼鐩綍鍙抽敭锛岄€夋嫨F5锛坮efresh锛?锛?锛夎缃甧clipse鑷姩鍒鋒柊銆?聽聽聽聽聽聽聽聽聽聽 閫氳繃Window->Preferences->General->Workspace锛岄€変腑Refresh automatically銆?

繼續閱讀