請高人幫我看看webwork使用Validator驗證的問題
xwork.xml:
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd";>
<xwork>
<include file="webwork-default.xml" />
<package name="default" extends="webwork-default">
<interceptors>
<interceptor-stack name="modelParamsStack">
<interceptor-ref name="params" />
<interceptor-ref name="model-driven" />
<interceptor-ref name="validationWorkflowStack" />
</interceptor-stack>
</interceptors>
<action name="login" class="MyTest.LoginAction">
<result name="success" type="dispatcher">
<param name="location">/main.jsp</param>
</result>
<result name="loginfail" type="dispatcher">
<param name="location">/index.jsp</param>
</result>
<interceptor-ref name="modelParamsStack" />
</action>
</package>
</xwork>
validators.xml:
<validators>
<validator name="required" class="com.opensymphony.webwork.validators.javascriptRequiredFieldValidator"/>
<validator name="requiredstring" class="com.opensymphony.webwork.validators.javascriptRequiredStringValidator"/>
<validator name="int" class="com.opensymphony.webwork.validators.javascriptIntRangeFieldValidator"/>
<validator name="date" class="com.opensymphony.webwork.validators.javascriptDateRangeFieldValidator"/>
<validator name="expression" class="com.opensymphony.xwork.validator.validators.ExpressionValidator"/>
<validator name="fieldexpression" class="com.opensymphony.xwork.validator.validators.FieldExpressionValidator"/>
<validator name="email" class="com.opensymphony.webwork.validators.javascriptEmailValidator"/>
<validator name="url" class="com.opensymphony.webwork.validators.javascriptURLValidator"/>
<validator name="visitor" class="com.opensymphony.webwork.validators.javascriptVisitorFieldValidator"/>
<validator name="conversion" class="com.opensymphony.xwork.validator.validators.ConversionErrorFieldValidator"/>
<validator name="stringlength" class="com.opensymphony.xwork.validator.validators.StringLengthFieldValidator"/>
</validators>
LoginAction-validation.xml:
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0//EN""http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd";>
<validators>
<field name="model.username">
<field-validator type="required">
<message>Please enter Username!</message>
</field-validator>
</field>
<field name="model.password">
<field-validator type="stringlength">
<param name="minLength">4</param>
<param name="maxLength">6</param>
<message>
Password length must between ${minLength} and ${maxLength} chars!
</message>
</field-validator>
</field>
</validators>
LoginAction.java:
package MyTest;
import java.util.Map;
import com.opensymphony.xwork.Action;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
import com.opensymphony.xwork.ModelDriven;
public class LoginAction extends ActionSupport implements Action,ModelDriven{
private final static String LOGIN_FAIL="loginfail";
LoginInfo loginInfo = new LoginInfo();
public String execute() throws Exception {
if ("erica".equalsIgnoreCase(loginInfo.getUsername())
&& "mypass".equals(loginInfo.getPassword())) {
//將當前登入的使用者名稱儲存到Session
ActionContext ctx = ActionContext.getContext();
Map session = ctx.getSession();
session.put("username",loginInfo.getUsername());
//出於演示目的,透過硬編碼增加通知訊息以供顯示
loginInfo.getMessages().add("message1");
loginInfo.getMessages().add("message2");
loginInfo.getMessages().add("message3");
return SUCCESS;
}else{
loginInfo.setErrorMessage("Username/Password Error!");
return LOGIN_FAIL;
}
}
public Object getModel() {
return loginInfo;
}
}
執行時後臺就出錯了! 異常:
2005-4-4 16:10:10 com.opensymphony.xwork.validator.ValidatorFileParser$2 fatalEr
ror
嚴重: White spaces are required between publicId and systemId. at (1:77)
2005-4-4 16:10:10 com.opensymphony.xwork.validator.ValidatorFileParser parseActi
onValidators
嚴重: Caught exception while attempting to load validation configuration file.
org.xml.sax.SAXParseException: White spaces are required between publicId and sy
stemId.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.document.uilderImpl.parse(Unknown Source)
at javax.xml.parsers.document.uilder.parse(Unknown Source)
at com.opensymphony.xwork.validator.ValidatorFileParser.parseActionValid
ators(ValidatorFileParser.java:81)
請高人幫我看看!!!!!
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd";>
<xwork>
<include file="webwork-default.xml" />
<package name="default" extends="webwork-default">
<interceptors>
<interceptor-stack name="modelParamsStack">
<interceptor-ref name="params" />
<interceptor-ref name="model-driven" />
<interceptor-ref name="validationWorkflowStack" />
</interceptor-stack>
</interceptors>
<action name="login" class="MyTest.LoginAction">
<result name="success" type="dispatcher">
<param name="location">/main.jsp</param>
</result>
<result name="loginfail" type="dispatcher">
<param name="location">/index.jsp</param>
</result>
<interceptor-ref name="modelParamsStack" />
</action>
</package>
</xwork>
validators.xml:
<validators>
<validator name="required" class="com.opensymphony.webwork.validators.javascriptRequiredFieldValidator"/>
<validator name="requiredstring" class="com.opensymphony.webwork.validators.javascriptRequiredStringValidator"/>
<validator name="int" class="com.opensymphony.webwork.validators.javascriptIntRangeFieldValidator"/>
<validator name="date" class="com.opensymphony.webwork.validators.javascriptDateRangeFieldValidator"/>
<validator name="expression" class="com.opensymphony.xwork.validator.validators.ExpressionValidator"/>
<validator name="fieldexpression" class="com.opensymphony.xwork.validator.validators.FieldExpressionValidator"/>
<validator name="email" class="com.opensymphony.webwork.validators.javascriptEmailValidator"/>
<validator name="url" class="com.opensymphony.webwork.validators.javascriptURLValidator"/>
<validator name="visitor" class="com.opensymphony.webwork.validators.javascriptVisitorFieldValidator"/>
<validator name="conversion" class="com.opensymphony.xwork.validator.validators.ConversionErrorFieldValidator"/>
<validator name="stringlength" class="com.opensymphony.xwork.validator.validators.StringLengthFieldValidator"/>
</validators>
LoginAction-validation.xml:
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0//EN""http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd";>
<validators>
<field name="model.username">
<field-validator type="required">
<message>Please enter Username!</message>
</field-validator>
</field>
<field name="model.password">
<field-validator type="stringlength">
<param name="minLength">4</param>
<param name="maxLength">6</param>
<message>
Password length must between ${minLength} and ${maxLength} chars!
</message>
</field-validator>
</field>
</validators>
LoginAction.java:
package MyTest;
import java.util.Map;
import com.opensymphony.xwork.Action;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
import com.opensymphony.xwork.ModelDriven;
public class LoginAction extends ActionSupport implements Action,ModelDriven{
private final static String LOGIN_FAIL="loginfail";
LoginInfo loginInfo = new LoginInfo();
public String execute() throws Exception {
if ("erica".equalsIgnoreCase(loginInfo.getUsername())
&& "mypass".equals(loginInfo.getPassword())) {
//將當前登入的使用者名稱儲存到Session
ActionContext ctx = ActionContext.getContext();
Map session = ctx.getSession();
session.put("username",loginInfo.getUsername());
//出於演示目的,透過硬編碼增加通知訊息以供顯示
loginInfo.getMessages().add("message1");
loginInfo.getMessages().add("message2");
loginInfo.getMessages().add("message3");
return SUCCESS;
}else{
loginInfo.setErrorMessage("Username/Password Error!");
return LOGIN_FAIL;
}
}
public Object getModel() {
return loginInfo;
}
}
執行時後臺就出錯了! 異常:
2005-4-4 16:10:10 com.opensymphony.xwork.validator.ValidatorFileParser$2 fatalEr
ror
嚴重: White spaces are required between publicId and systemId. at (1:77)
2005-4-4 16:10:10 com.opensymphony.xwork.validator.ValidatorFileParser parseActi
onValidators
嚴重: Caught exception while attempting to load validation configuration file.
org.xml.sax.SAXParseException: White spaces are required between publicId and sy
stemId.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.document.uilderImpl.parse(Unknown Source)
at javax.xml.parsers.document.uilder.parse(Unknown Source)
at com.opensymphony.xwork.validator.ValidatorFileParser.parseActionValid
ators(ValidatorFileParser.java:81)
請高人幫我看看!!!!!
相關文章
- 請幫我看看呼叫webservice的問題謝謝!Web
- 使用Validator做SpringMVC的驗證框架 - Validator前端驗證SpringMVC框架前端
- 請各位幫我看看javamail的問題(本不應在這裡提這類問題,但在csdn實在沒人幫我解答)JavaAI
- 請教個jf和webwork的問題Web
- jf6.2初學者問題,請大家幫忙看看
- 一個執行緒的問題。請大俠進來幫幫忙看看執行緒
- (1.5年 測試經驗) 關於簡歷,請各位幫我看看。
- 請各位高人幫我指點一下我的職業規劃!謝謝了!(5年多工作經驗)
- 關於分散式異構系統的問題!請幫忙看看分散式
- 安裝JPETSTORE出錯,請幫忙看看是哪出了問題.
- banq老師.使用jdonFramework遇到錯誤,請幫我看看什麼原因.Framework
- 第一次法帖,哪位能幫我看看jboss伺服器登陸認證的問題?伺服器
- 關於digest認證的問題,請高手幫忙
- 使用 Spring Validator 介面實現驗證Spring
- 求教:webwork配置問題Web
- validator驗證框架之理解框架
- 初學news例子的一個問題,不知道原因,高手幫我看看
- 急,急,急,請教高手struts驗證的問題!
- Laravel 驗證器 Validator::make 的用法Laravel
- 幫我看看如何解決?
- 酷 Go 推薦 Validator 網路請求資料驗證包Go
- 各位高手來幫我看看sql的問題吧,謝謝啦,線上等答案啊SQL
- 在非Laravel專案中使用Validator驗證器Laravel
- 郵件傳送程式,用到了模版模式,幫我看看有啥問題。模式
- 我們來看看翻譯中的問題
- 使用Validator做SpringMVC的驗證框架 - 配置SpringMVC環境SpringMVC框架
- validator 驗證框架(學習筆記)框架筆記
- Laravel POST 請求 API 介面,使用自定義表單驗證,驗證失敗跳轉回首頁的問題記錄LaravelAPI
- Jbuilder 問題,請大俠幫忙!!!UI
- Django筆記四十二之model使用validator驗證器Django筆記
- HTTPS請求筆記- SSL安全通道驗證問題HTTP筆記
- struts的validator框架問題?急框架
- 安裝出錯,請幫忙看看(轉)
- 使用Hibernate-Validator優雅的驗證RESTful Web Services的引數RESTWeb
- NPM酷庫041:validator,驗證工具集合NPM
- SAR-303 xml validator驗證框架XML框架
- 哪位兄臺幫我看看JIVE安裝問題, 資料庫連線出錯!加急!!!資料庫
- 安裝crs使用runcluvfy驗證的一個問題