简体   繁体   English

无法使用Struts2拦截器验证图像上传表单

[英]unable to validate image upload form using struts2 interceptor

i am trying to put validation into my image upload form using struts2 interceptor if users submits invalid image extension there there should be validation error message? 我正在尝试使用struts2拦截器将验证放入我的image upload表单中,如果用户提交了无效的图像扩展名,那么应该出现验证错误消息?

uploadThemeImage.jsp uploadThemeImage.jsp

<s:form action="updatethemeimageform"  method="post" enctype="multipart/form-data" id="remoteform"  theme="simple" >
     <s:hidden value="%{#parameters.themeid}" name="themId"/>  
      <s:file name="thempic" label="Theme Screenshot" /> 
      <sj:a button="true" id="btnsid" buttonIcon="ui-icon-gear" dataType="json" indicator="indicator"  onSuccessTopics="reloadMyGrid,handleJsonResult"  
        formIds="remoteform" targets="result">Submit This Form</sj:a>  </s:form>

You can't see the error if you don't put an <s:fielderror /> tag in your JSP. 如果未在JSP中放置<s:fielderror />标记,则看不到错误。

Add it before <s:form> and you will see your validation error... <s:form>之前添加它,您将看到验证错误...

PS: the same applies to <s:actionmessage /> and <s:actionerror > (that are not involved with the validation but added by you) PS: <s:actionmessage /><s:actionerror > (不涉及验证,而是由您添加)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM