在textfield中的Struts2 / css [英] Struts2 / css in textfield

查看:130
本文介绍了在textfield中的Struts2 / css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从struts2编程开始,我想知道如何做下面的事情。我有这样的struts代码:

 < s:textfield name =aName/> 

在使用struts2之前,我有了这个html代码:

 < input id =aLogintype =textclass =form-controlname =usernamevalue =placeholder =somethingrequired autofocus> 

我怎样才能合并这两行来执行相同的html代码,但使用我的struts2代码?

解决方案在Struts标签中, class ans style 变成 cssClass cssStyle ;在旧版本的Struts中, required 是一个属性,指示何时将 * 标记更改为 requiredLabel 以避免重写HTML5必需的属性。可以设置其他HTML5属性,如 placeholder autofocus ,因为Textfield标记允许动态属性

然后在您的案例中:

 < s:textfield id =aLogin
name =aName
cssClass =form-control
value =
placeholder =something
required
自动对焦/>

有关其他信息,请参阅官方< s:textfield /> 文档


I am beginning with struts2 programming and I wondered how I could do the following thing. I have this struts code in a form :

<s:textfield name="aName"/>

And I had this html code before using struts2 :

<input id="aLogin" type="text" class="form-control" name="username" value="" placeholder="something" required autofocus>

How could I "merge" these two lines to do the same html code but using my struts2 code ?

解决方案

In Struts tags, class ans style becomes cssClass and cssStyle; in old versions of Struts, required was an attribute indicating when to put the * mark, now changed to requiredLabel to avoid overriding the HTML5 required attribute. Other HTML5 attributes like placeholder and autofocus can be set because Textfield tag Allows Dynamic Attributes.

Then in your case:

<s:textfield id = "aLogin" 
           name = "aName" 
       cssClass = "form-control" 
          value = ""
    placeholder = "something" 
       required
      autofocus />

For other info, refer to the official <s:textfield/> documentation

这篇关于在textfield中的Struts2 / css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆