請查看struts-config.xml中的定義部分,有時可能是打錯了字符或者是某些不符合規則,可以使用struts console工具來檢查。
建議你分開來做,如果是用MyEclipse的話,先加載Struts,然後寫一個簡單的登錄程序,後臺不用數據庫,看能否成功,如果用驗證的話,再加上validator,看能否成功,然後再載Spring,看能否成功,再加上Hibernate,
******** Eclipse 版本不同的問題 ********
The type java.lang.Object cannot be resolved.It is indirectly referenced from required.class files。
1、The type java.lang.Object cannot be resolved.It is indirectly referenced from required.class files。
出現以上信息的原因是因爲你裝了多個版本的jre或jdk的關係。本來Eclipse在建立工程時,會自動參 照你的jre路徑,但多個版本就沒辦法了。
你只能手動建立…
a. 進入window/preferences/java/Installed JREs
1)按Add
2)輸入JRE Name, 例JDK1.5.0.03
3)JRE home directory, 選擇安裝的路徑
4)按OK
b. 進入Project/properties/Java Bulid Path
1)Add library
2)選JRE System Library後按Next
3)選workplace default JRE後按finish...
2、The import javax.servlet cannot be resolved
上面問題的解決辦法如下:將servlet-api.jar(在%TOMCAT_HOME%//common/lib目錄下面可以找 到 這個文件)或者javaee.jar導入每個動態web工程。
******** Asp.net 中的isPostBack ********
//哈哈,爲什麼JSF中沒有呢,自己寫一個吧。
public boolean isPostBack( ) {
if( getFacesContext().getRenderResponse() )
return false;
else
return true;
}
******錯誤******
java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;
在網上多翻查找均未能解決,後終於摸索出解決之道,辦法如下:
從網上下一個最新的asm-all-3.0.jar的jar包,然後把原來的所有asm開頭的jar包全部刪掉,還有一個cglib-2.1.3.jar也刪掉.
******錯誤******
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax)
log4j:WARN Please initialize the log4j system properly.
2006-11-9 9:46:51 org.apache.catalina.core.StandardContext start
嚴重: Error listenerStart
少log4j.properties 從Tomcat所帶的示例中拷一個放到/WEB-INF/classes下
**********Spring 啓動慢**********
仔細看了spring的源代碼,發現主要是spring的beans,默認default-lazy-init爲false,導致在啓動時候,會默認加載整個對象實例圖,導致速度慢
把beans的default-lazy-init改爲true的話,spring在啓動的時候並沒有真正實例化對象,而只是用一個代理來實現。當真正需要調用該類的時候,纔會去實例化。更重要的是spring的實例化對象效率是不高的,需要花費很多時間。這樣在運行期間第一次點頁面的時候,會加載一部分需要的beans,所以稍微慢2-3秒鐘,但是這相對於一次性加載花費的50秒鐘要輕鬆很多
JDK 1.4 + Spring 1.2 + hibernate 3.1 + Tomcat 5.0 + Struts 1.2
**************導入spring到庫錯誤**************
Unable to install all Spring libraries.
Reason:
Unable to access project 's build-path
是不是 把spring下的所有 lib 都選擇了 ,注意 你選擇hibernate2 就不要選hibernate3 2者只應當選其一 否則會有 訪問工程的構建路徑 的衝突 nable to access project 's build-path
the jar file struts.jar has no source attachment
***************************************
因爲你沒有關聯源代碼。這個是可以設置的。在出現上述錯誤的界面有個按鈕,名稱叫“Attach Source……”點擊進去就可以設置了。
No connection properties specified - the user must supply JDBC connections
org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
*******************************************
spring + hibernate 是報上面的錯,原因是,配置文件,hibernate.cfg.xml文件必須放在src目錄下.
同時.配置文件各屬性如下:
<session-factory>
<property name="show_sql">true</property>
<!-- <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>-->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/demodb</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<mapping resource="com/sterning/books/model/books.hbm.xml"/>
<!--
<class-cache class="org.hibernate.auction.Item" usage="read-write"/>
<class-cache class="org.hibernate.auction.Bid" usage="read-only"/>
<collection-cache collection="org.hibernate.auction.Item.bids" usage="read-write"/>
-->
</session-factory>
java.lang.IllegalArgumentException: argument type mismatch
*************************************************************************
錯誤原因:jsp頁面中表單標記庫類型與form表單的enctype屬性值不匹配。_4F(WCco
解決方法:設置正確的enctype屬性值。
<html:form action="" enctype="multipart/form-data">
BeanUtils.populate&argument type mismatch - [Struts]
1.繼承ActionForm的類的所有字段必須爲String型
2.由於Date型轉換爲String需設置DateFormat,所以你的Bean裏的日期字段最好用String
這樣就不會出現類型轉換錯誤了。
今天做Struts框架的JSP網站,到執行插入頁面時,本應是往數據庫插入數據,結果拋出 “java.lang.IllegalArgumentException: argument type mismatch”,百思不得其解(根本就不會,想破腦袋也不能解)從網絡上找資料,很多人說是form那出的問題,按方法解之,未果。後來上論壇問,原來是頁面數據綁定到form 時數據類型不匹配(尤其注意不是String類型的),改之,問題解決!
還有很重要的一點就是看eclipse中的報錯信息!!!
struts + spring 出現 HTTP Status 404 - Servlet action is not available
************************************************************************
拷貝commons-beanutils.jar和commons-digester.jar到WEB-INF/lib.
Cannot retrieve mapping for action
**********************************************************
異常
javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login (/Login是你的action名字)
可能原因
action 沒有再struts-config.xml 中定義,或沒有找到匹配的action,例如在JSP文件中使用 <html:form action="Login.do".將表單提交給Login.do處理,如果出現上述異常,請查看struts-config.xml中的定義部分,有時可能是打錯了字符或者是某些不符合規則,可以使用struts console工具來檢查。
The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".
**********************************************************
在添加過濾器的時候,把所有的<servlet-mapping>都放到<servlet>元素之後,