简体   繁体   English

Struts验证框架:“验证摘要”为空白

[英]Struts Validation Framework: Validation Summary is blank

BACKGROUND 背景

I am learning Struts 1.x and currently on the validation framework. 我正在学习Struts 1.x,目前正在验证框架上。

PROBLEM 问题

I have it in a semi-working condition. 我处于半工作状态。 Currently it is showing the validation errors, but in a javascript alert.. and then the validation summary (the thing generated by <html:error> ) is blank.. well, it has 3 bullet points where the validation errors are supposed to be, but no text. 当前它显示验证错误,但是在javascript警报中..然后验证摘要(由<html:error>生成的东西)为空白..嗯,它有3个要点,验证错误应该是,但没有文字。

  1. I would not have expected it to use a javascript alert. 我不会期望它使用JavaScript警报。 I only want the validation summary. 我只想要验证摘要。 How can I turn this off, if possible? 如果可能,如何关闭此功能?
  2. Why is the validation summary missing text? 为什么验证摘要缺少文本?

EDIT 编辑

Here is some of the code, if it helps. 如果有帮助,这里有一些代码。

struts-config.xml struts-config.xml

<form-beans>
        <form-bean name="ProductActionForm" type="actionForms.ProductActionForm"/>
    </form-beans>

validation.xml validation.xml

<form name="ProductActionForm">
            <field property="name" depends="required">
                <arg key="ProductActionForm.name"/>
            </field>
            <field property="price" depends="required,float">
                <arg key="ProductActionForm.price"/>
            </field>
            <field property="quantityInStock" depends="integer,intRange">
                <arg0 key="ProductActionForm.quantityInStock"/>
                <arg1 name="intRange" key="${var:min}" resource="false"/>
                <arg2 name="intRange" key="${var:max}" resource="false"/>
                <var>
                    <var-name>min</var-name>
                    <var-value>0</var-value>
                </var>
                <var>
                    <var-name>max</var-name>
                    <var-value>9999</var-value>
                </var>
            </field>
        </form>

JSP HTML: JSP HTML:

<html:javascript formName="ProductActionForm" />
        <html:errors></html:errors>
        <html:form action="/AddProductAction" method="post" onsubmit="validateProductActionForm(this);">
            <table class="table table-striped">
                <tbody>
                    <tr>
                        <td>Name: </td>
                        <td><html:text property="name" /></td>
                    </tr>
                    <tr>
                        <td>Price: </td>
                        <td><html:text property="price" /></td>
                    </tr>
                    <tr>
                        <td># In Stock </td>
                        <td><html:text property="quantityInStock" /></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><input type="submit" class="btn btn-primary" value="Submit" /></td>
                    </tr>
                </tbody>
            </table>
        </html:form>

EDIT 2 编辑2

Here are some screenshots: 以下是一些屏幕截图:

Showing javascript alert: 显示JavaScript警报: 显示JavaScript警报

Showing blank validation summary: 显示空白的验证摘要: 显示空白验证摘要

Hi Matt Here we go There are 2 types of Struts1 Validations 嗨,马特,我们来了。Struts1验证有2种类型

1. Validate using ActionErrors validate in Bean itself(show summary) 1.使用ActionErrors在Bean本身中进行验证(显示摘要)

2. Validate using xml and configure everything here itself.(javascript alert) 2.使用xml进行验证,并在此处自行配置所有内容。(javascript警报)

for your case you used second type that is correct,But to get summary alone check this link thats all, if you get problem in link or its example , Please ping me. 对于您的情况,您使用的是正确的第二种类型,但是要单独获取摘要,请检查此链接,如果您在链接或其示例中遇到问题,请ping我。

This is the example 这是例子

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

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