1. 程式人生 > >Struts2錯誤:Developer Notification (set struts.devMode to false to disable this message)

Struts2錯誤:Developer Notification (set struts.devMode to false to disable this message)

Struts2發現錯誤: 

2018-12-18 23:44:34,136 [http-bio-8082-exec-8] ERROR com.opensymphony.xwork2.interceptor.ParametersInterceptor - Developer Notification (set struts.devMode to false to disable this message):

Unexpected Exception caught setting 'repassword' on 'class cn.tx.controller.EmpAction: Error setting expression 'repassword' with value ['123456', ]
 

剛剛看到這個問題的時候,可能是以下幾種情況:

1.傳輸的資料型別與setting"XXX"的資料型別不匹配。

    執行:查找了所有相關資料,沒有任何結果。

2.Action當中沒有寫‘XX’的setter方法。

   執行:在Action中新增get和set方法,同樣還是沒有結果。

3.輸入值超出了範圍。

   想想:不可能,用的是Integer型別,怎麼可能會超出範圍。

當再次回到問題時,發現自己忽略了:Developer Notification (set struts.devMode to false to disable this message)。

原因分析:

當struts.devMode設定為true時,html表單資料中有和action屬性匹配不上的引數名時就會被這樣顯示出來,沒什麼大礙,就是為了便於使用者除錯。struts.devMode設定為false就沒有了。可能它的log級別設定的容易讓人忽略。

執行:

將struts.devMode設定為false,程式碼如下:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
	"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
	<constant name="struts.devMode" value="false"></constant>
	<constant name="struts.ui.theme" value="simple"></constant>
	
	<package name="erp" extends="struts-default">

	   <action name="erp_*">
			<result>/WEB-INF/jsps/{1}.jsp</result>
	   </action>	
		 
	   <action name="emp_*" class="empAction" method="emp_{1}">
			<result name="success">/WEB-INF/jsps/emp/{1}.jsp</result>
	   </action>
	   
	   <action name="ajax_emp_*" class="empAction" method="ajax_emp_{1}"/>
	   	
	   <action name="dep_*" class="depAction" method="dep_{1}">
			<result name="success">/WEB-INF/jsps/dep/{1}.jsp</result>
	   </action>
	</package>
	
</struts>

重新配置後,重啟Tomcat,Struts2的錯誤就消失了。

 

作者:Roger_CoderLife

連結:https:blog.csdn.net/Roger_CoderLife/article/details/85085430

本文為Roger_CoderLife的原創文章,著作權歸作者所有,轉載請註明原文出處,歡迎轉載!