user2265669
user2265669

Reputation:

How to add CSS on Struts 2 form page?

In my Struts 2 application I am trying to add CSS style, but it is not displaying on the page. When I click on the submit button two times, and after showing a validation error, only then, the CSS is displaying. Please tell me what is the resolve of this kind of problem? my form is here

<%@ 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>&nbsp;</td></tr>
        <tr>
    <td>&nbsp;</td>
      <s:submit align="center"></s:submit>
      </s:form>
       </div>
    </body>
 </html>

CSS file is:

#did
{background-color:#6495ed;}

#trasition
{
transition: width 2s;
-webkit-transition: width 2s; 
} 

Upvotes: 2

Views: 3065

Answers (1)

Roman C
Roman C

Reputation: 1

You have mistake with the syntax of the style attribute

you should replace this

cssStyle="{width:184px"

to

cssStyle="width:184px;"

also dojo tag library is deprecated in struts2 since version 2.1. Use struts2-jquery instead.

Upvotes: 1

Related Questions