Вопрос

I have created a struts2 login page, wherein I have all basic components necessary for login. I'm using struts2 text tag for a label. Below is my login page code snippet.

  <body>
        <h2>Demo - Login</h2>
        <s:actionerror />
        <s:form action="login.action" method="post">
            <s:textfield name="username" key="label_username" size="20" />
            <s:password name="password" key="label_password" size="20" />
            <s:submit name="signIn" key="label_login" align="center" />
            <s:text name="name_msg"/>
            <s:submit name="signUp" key="label_signUp"></s:submit>
        </s:form>
    </body>

I always see that text(New to Demo ?) is displayed after heading, as shown in below Image. There text is read from MessageBundle. I tried by giving some direct text value, despite of referring to resource bundle, even though same result. Where I was wrong.

enter image description here

Это было полезно?

Решение

The <s:text> tag displays text with no "decoration".

The default "xhtml" theme's form tags emit table markup.

This means you're currently generating invalid HTML, so the text will show up in essentially arbitrary locations based on how the browser handles stuff showing up in between table rows.

Viewing the source would have answered this question immediately.

You need to either put the text into a table row, as with everything else in the form tag, or use the "simple" theme and do all the layout, error messages, etc. yourself.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top