在我的 Struts 2 应用程序中,我尝试添加 CSS 样式,但它没有显示在页面上。当我点击提交按钮两次并显示验证错误后,only,CSS 才会显示。请告诉我这种问题的解决办法是什么? 我的表格在这里
<%@ page language ="java" contentType ="text/html; charset=ISO-8859-1" pageEncoding ="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/struts-dojo-tags" prefix="sx" %>
<html>
<head>
<sx:head/>
<script type="text/javascript" src ="script.js"></script>
<link rel="stylesheet" type="text/css" href="css/emp.css">
</head>
<body>
<div id ="did" align="center"> <h1 style="color: red"> ENPLOYEE REGISTRATION FORM</h1>
<s:form action="emplogin" method="post" >
<s:textfield name="firstname" label="Employee Firstname"/>
<s:textfield name ="lastname" label ="Last name"/>
<s:textfield name ="id" label="Id"/>
<s:radio name ="gender" list="{'male', 'female'}" label = "Gender"/>
<sx:datetimepicker name="dob" displayFormat="dd-MMM-yyyy" label="DOB"></sx:datetimepicker>
<s:radio name ="maritalstatus" list="{'singale','married'}" label="Marital Status" />
<s:textfield name ="email" label ="Email" />
<sx:datetimepicker name ="joiningdate" displayFormat="dd-MMM-yyyy" label="Joining Date" ></sx:datetimepicker>
<s:textfield name= "designation" label = "Designation"/>
<s:textarea name ="address" label ="Address" />
<s:textfield name = "country" label ="Country" />
<s:textfield name ="state" label = "State" />
<s:textfield name ="city" label ="City"/>
<s:textfield name ="pincode" label ="Pincode"/>
<s:textfield name ="mobileno" label="Mobile No"/>
<s:select name ="groups" list="{'group 1', 'group 2', 'group 3'}" label ="Group" />
<tr><td> </td></tr>
<tr>
<td> </td>
<s:submit align="center"></s:submit>
</s:form>
</div>
</body>
</html>
CSS文件是:
#did
{background-color:#6495ed;}
#trasition
{
transition: width 2s;
-webkit-transition: width 2s;
}
您的样式属性语法有误
你应该更换这个
cssStyle="{width:184px"
到
cssStyle="width:184px;"
自 2.1 版起,struts2 中不再推荐使用 dojo 标签库。使用 struts2-jquery 代替。