struts-config.xml中的元素有嚴格的順序,如果元素的順序出錯,系統會抛出一個錯誤,描述如下:
The content of element type "struts-config" must match "(display-name?,description?,data-sources?,form-beans?,global-exceptions?,global-forwards?,
action-mappings?,controller?,message-resources*,plug-in*)". [109]
剛看到這個錯誤,我總以為是某個元素的拼寫出了錯誤,把整個檔案仔細檢查了一遍,沒有發現任何拼寫作錯誤。查了資料才知道,struts-config.xml中的元素有嚴格的順序,他們的順序應該是象下面這個樣子:<struts−config>
<data−sources>
<data−source>
</data−source> </data−sources>
<form−beans>
<form−bean />
</form−beans>
<global−forwards>
<forward />
</global−forwards>
<action−mappings>
<action/>
</action−mappings>
<controller />
<message−resource />
<plug−in />
</struts−config>
上面的錯誤提示不是說元素有拼寫錯誤,而是說struts-config.xml必須按照display-name-->description-->datasources-->form-beans-->global-forwards-->action-mappings-->controller-->message_resources-->plug-in的順序書寫否則就會報錯。