1. 程式人生 > >Struts2入門錯誤集合

Struts2入門錯誤集合

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException 少匯入了:javassist-3.20.0-GA.jar

第二種:指定多個action時在這裡插入圖片描述 原因: struts2.5 為了增加安全性,在 struts.xml 添加了這麼個屬性:

<global-allowed-methods>regex:.*</global-allowed-methods>

解決方法:(圖片中藍色部分)在這裡插入圖片描述

第三種:(編譯時報錯)

ERROR DomHelper 元素型別為 "package" 的內容必須匹配 "(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-class-ref?,global-results?,global-allowed-methods?,global-exception-mappings?,action*)"。 at (null:27:15)

第四種:(修改struts字尾時報錯) 在這裡插入圖片描述 在這裡插入圖片描述 原因:當struts2的"url-pattern"設定為"/*"時,此時Struts2的副檔名就預設為.action,無論你怎麼改字尾名,都會404 解決方法:(1)在配置檔案web.xml的filter中加入

<init-param>
	<param-name>struts.action.extension</param-name>
	<param-value>html</param-value>
</init-param>			

解決方法(2):在配置檔案struts.properties

中加入以下程式碼;修改多種時,逗號隔開即可 struts.action.extension = action,do,struts2,