DOC

errors

By Leonard Washington,2014-10-09 10:20
6 views 0
errors

错误信息由ActionFromAction包装在ActionErrors中返回,

    并存放在由字符串常量Action.ERROR_KEY指定的Bean, 被传

    递回View组件(.jsp 文件), 这个Bean被保存在请求范围内

    (request Attribute). <html:errors>标记在JSP文件被处

    理时, 首先会看看这个Bean是否存在, 如果这个Bean存在,

    会认为由错误要显示.

    指定全局错误使用ActionErrors.GLOBAL_ERROR作为

    ActionErrors key.

    创建消息使用:

    errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("ch12.global.error") )

    显示消息用:

    <html:errors

    property="org.apache.struts.action.GLOBAL_ERROR"/>

    字符串"org.apache.struts.action.GLOBAL_ERROR"是别名

    ActionErrors.Global的实际值

    Displays a set of error messages prepared by a business logic component and stored as an ActionErrors object, a

    String, or a String array in request scope. If such a bean is not found, nothing will be rendered.

    In order to use this tag successfully, you must have defined an application scope MessageResources bean under

    the default attribute name, with optional definitions of the following message keys:

    ; errors.header - Text that will be rendered before

    the error messages list. Typically, this message

    text will end with <ul> to start the error messages

    list.

    ; errors.footer - Text that will be rendered after

    the error messages list. Typically, this message

    text will begin with </ul> to end the error

    messages list.

    ; errors.prefix - Text that will be rendered before

    each individual error in the list.

    ; errors.suffix - Text that will be rendered after

each individual error in the list.

    Attribute Description Name

    The servlet context attribute key for the

    MessageResources instance to use. If not specified, bundle defaults to the application resources configured

    for our action servlet. (RT EXPR)

    The session attribute key for the Locale used to

    locale select messages to be displayed. If not specified,

    defaults to the Struts standard value. (RT EXPR)

    Name of the request scope bean under which our

    error messages have been stored. If not present, name the name specified by the Action.ERROR_KEY constant

    string will be used. (RT EXPR)

    Name of the property for which error messages

    should be displayed. If not specified, all error property messages (regardless of property) are displayed.

    (RT EXPR)

Report this document

For any questions or suggestions please email
cust-service@docsford.com