struts 2标签不会生成标签

时间:2013-06-19 18:32:45

标签: java css struts2 tags

我有一张表格:

<!-- Box Start-->
    <div id="box_bg">
        <div id="content">
            <h1 class="blue">Edit an exam</h1>
            <!-- Exam Fields -->
            <s:form theme="simple" action="editExam">
                <div >
                    <s:hidden name="exam.id" />
                    <s:textfield name="exam.name" cssErrorClass="register error" label="Exam Name" cssClass="register" required="" />
                    <s:textfield name="exam.minutesAllotted" label="Minutes Allotted" cssErrorClass="register error" cssClass="register" required="" />
                    <s:textfield name="exam.numQuestions" label="Number Of Questions" cssErrorClass="register error" cssClass="register" required="" />
                    <sj:datepicker readonly="true" name="exam.startDate" cssClass="register" label="Start Date" displayFormat="mm/dd/yy" required="" />
                    <sj:datepicker readonly="true" name="exam.endDate" cssClass="register" placeholder="End Date" displayFormat="mm/dd/yy" required="" />
                </div>
                <!-- Blue Button -->
                <s:submit type="button" cssClass="button blue" value="Edit" />
            </s:form>
        </div>
    </div>

使用以下css:

html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video
    {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}

article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section
    {
    display: block;
}

body {
    line-height: 1;
}

/** Base Body Styles **/
body {
    background: url(../images/body-bg.png);
    color: #838383;
    font: 13px "Droid Sans", Arial, Helvetica, sans-serif;
}

h1,h2,h3,h4,h5,h6 {
    font-weight: bold;
    font-family: 'Droid Sans', sans-serif;
    color: #434853;
    text-shadow: 0px 1px 0px #fff;
    letter-spacing: -0.5px;
}

h1 {
    font-size: 20px;
    color: #2d932b;
    padding: 0 0 13px 0;
    border-bottom: 1px solid #e0e0e0;
}

input,textarea {
    font-family: tahoma, arial;
    font-size: 12px;
    color: #57595d;
}

p {
    line-height: 20px;
}

#box_bg {
    border: 1px solid #d5d5d5;
    background: #f9f9f9;
    width: 380px;
    display: block;
    margin: 50px auto 20px auto;
    -webkit-border-radius: 10px;
    -moz-border-radius: 3px;
    border-radius: 3px;
    box-shadow: 0px 0px 2px #dadada, inset 0px -3px 0px #e6e6e6;
    padding-bottom: 50px;
}

#content {
    padding: 23px 28px;
}

.blue {
    color: #2b83b6;
}

.button {
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
    display: inline-block;
    float: right;
    margin-top: 18px;
}

.button a {
    padding: 9px 26px 8px 26px;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    display: block;
}

.button.blue {
    background-image: linear-gradient(bottom, #1F7FB6 0%, #4EABE0 100%);
    background-image: -o-linear-gradient(bottom, #1F7FB6 0%, #4EABE0 100%);
    background-image: -moz-linear-gradient(bottom, #1F7FB6 0%, #4EABE0 100%);
    background-image: -webkit-linear-gradient(bottom, #1F7FB6 0%, #4EABE0 100%);
    background-image: -ms-linear-gradient(bottom, #1F7FB6 0%, #4EABE0 100%);
    background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #1F7FB6),
        color-stop(1, #4EABE0));
    -ms-filter:
        "progid:DXImageTransform.Microsoft.gradient(startColorstr=#4EABE0, endColorstr=#1F7FB6)";
    border: 1px solid #2a76a2;
    border-bottom: 2px solid #215f82;
    box-shadow: inset 0px 1px 0px #9cd0ee;
    text-shadow: -1px -1px 0px #246c95;
    background-color: #3897cd;
    padding: 9px 26px 8px 26px;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    display: block;
}

.button.blue:hover {
    background: #3897cd;
}

.button.blue:active {
    margin-top: 19px;
}

/** Register Fields **/
.register {
    font-size: 14px;
    color: #8e8d8d;
    font-family: "Droid Sans";
    padding: 11px 15px 10px 15px;
    background-color: #fdfdfd;
    width: 290px;
    display: block;
    border: 1px solid #d8d8d8;
    margin: 13px 0 -3px 0;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
    box-shadow: inset 2px 2px 4px #f1f1f1;
}

.register.error {
    border: 1px solid #f19d9d;
    background-color: #ffe0e0;
    box-shadow: inset 0px 0px 0px #fff;
    color: #d95e5e;
}

#blue {
    color: #2b83b6 !important;
}

#blue:hover {
    color: #878787 !important;
}

由于某种原因,标签未生成。当我查看生成的html时,它就是:

<input name="exam.id" value="7" id="editExam_exam_id" type="hidden">
                    <input name="exam.name" value="Physics" id="editExam_exam_name" class="register" required="" type="text">
                    <input name="exam.minutesAllotted" value="30" id="editExam_exam_minutesAllotted" class="register" required="" type="text">
                    <input name="exam.numQuestions" value="100" id="editExam_exam_numQuestions" class="register" required="" type="text">
                    ....

如何在保留格式的同时标记所有这些字段?这就是目前的样子: http://imgur.com/PSfeHlN

1 个答案:

答案 0 :(得分:0)

"simple"主题不会生成标签。

您可以使用纯HTML标签字段和<s:text>创建标签。

或者,如果您将在整个网站中使用此格式,请创建自己的主题并修改模板发出的HTML,以便将标签放置在您想要的位置。

另外考虑使用"css_xhtml"主题并仅使用CSS来重新定位元素,尽管这条路线有一些“陷阱”,就像某些模板中不幸的遗留<br/>标记一样。