亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

程序員小白的提問 +__+、:struts+spring配置問題

程序員小白的提問 +__+、:struts+spring配置問題

熊貓程序員 2017-03-30 12:20:27
案例目錄spring.xml配置<!-- dispartchAction配置 --><bean id="dispartchAction" class="sshDemo1.action.DispatchAction"scope="prototype"></bean><!-- userAction配置 --><bean id="userAction" class="sshDemo1.action.UserAction"scope="prototype"></bean>struts配置<struts>?<constant name="struts.i18n.encoding" value="UTF-8"></constant>?<constant name="struts.action.extension" value="html"></constant>?<constant name="struts.enable.DynamicMethodInvocation" value="false"></constant>?<package name="packageDemo1" extends="struts-default" namespace="/">?<!-- 注意:在struts2.3以后使用通配符配置需要將struts.enable.DynamicMethodInvocation=false? ? ? ? ? 同時,在package下配置global-allowed-methods或配置在action下配置allowed-methods? ?-->? <global-allowed-methods>login,index</global-allowed-methods>? <action name="dispartchAction_*" class="dispartchAction" method="{1}">? ?<result name="index">/WEB-INF/index.jsp</result>? ?<result name="login">/WEB-INF/login.jsp</result>? </action>? <action name="userAction_*" class="userAction" method="{1}">? ?<result name="success">/WEB-INF/success.jsp</result>? ?<result name="login">/WEB-INF/login.jsp</result>? </action>?</package></struts>web.xml配置? <context-param>? ?<param-name>contextConfigLocation</param-name>? ?<param-value>classpath:spring.xml</param-value>? </context-param>? <listener>? ?<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>? </listener>? <filter>? ?<filter-name>struts2</filter-name>? ?<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>? </filter>? <filter-mapping>? ?<filter-name>struts2</filter-name>? ?<url-pattern>/*</url-pattern>? </filter-mapping>index.jsp頁面<a href="${pageContext.request.contextPath}/dispartchAction_login.html">登錄</a>login.jsp頁面 <form action="${pageContext.request.contextPath}/userAction_login.html" method="post">當訪問index.jsp和在index.jsp跳轉到login.jsp的時候,程序沒有錯誤,但是當登錄訪問userAction的時候報錯,說找不到userAction對象。HTTP Status 500 - Unable to instantiate Action, userAction, defined for 'userAction_login' in namespace '/'Cannot find class [sshDemo1.action.UserAction] for bean with name 'userAction' defined in class path resource [spring.xml]; nested exception is java.lang.ClassNotFoundException: sshDemo1.action.UserAction求解?謝謝!??!。。。。
查看完整描述

3 回答

已采納
?
你的女友漏氣了

TA貢獻3條經驗 獲得超0個贊

錯誤信息寫的清清楚楚啊

查看完整回答
反對 回復 2017-03-31
  • 熊貓程序員
    熊貓程序員
    我看那錯誤應該是找不到userAction這個類對象,但是我在spring.xml中配置了這個類 <!-- userAction配置 --> <bean id="userAction" class="sshDemo1.action.UserAction" scope="prototype"></bean> 我訪問dispartchAction的時候可以訪問,也就說明加載到了配置文件spring,但是當點擊登陸,表單提交找userAction的時候就報錯,我就感覺和差異,我覺得是spring.xml文件沒有創建到這個對象,所以報錯。但是為什么前面的能夠找到dispathAction,后面userAction的找不到。
?
younghu

TA貢獻25條經驗 獲得超6個贊

你form表單action 寫錯了吧。不是xx.action嗎
查看完整回答
反對 回復 2017-04-01
?
熊貓程序員

TA貢獻7條經驗 獲得超0個贊

我剛剛認真看了一遍,將改了一下dispartchAction-->dispatchAction然后將服務器clear了一下,然后從新啟動了一下,就可以了#_#,具體情況我覺得可能是服務器緩存了數據沒有更新,但是昨天確實是重啟服務器了,就是不行。哎~,真心累,。。。。。。。。

查看完整回答
反對 回復 2017-03-31
  • 3 回答
  • 0 關注
  • 2309 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號