Struts 2: textbox label is not displayed

纵饮孤独 提交于 2020-05-14 01:38:10

问题


I am new to Struts 2 and started to build my new application. I created a JSP page with simple textbox and a button but my textbox labels are not getting displayed. here is my JSP code,

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

 <%@ taglib prefix="s" uri="/struts-tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Enter Outbound details</title>
</head>
<body>

    <s:form action="outbound.action" method="post">
    <h1> Enter required details for fetching outbound log</h1>

    <s:textfield label="StationId" name="StationId" size="20" />
    <s:textfield label="Username" name="username" />
    <s:submit method="execute" value="Submit" align="center" />


    </s:form>
</body>
</html>

My output is (sorry i could not paste the image),

Enter required details for fetching outbound log

textbox textbox sumbit_button

I could see only the textbox. I cant find the label. I am not sure where I am making the mistake. Please let me know in case if any additional details are needed.


回答1:


Labels are rendered if xhtml or css_xhtml themes applied. Themes are also used for other markup injected into the document via templates. You should either change the default theme used for every page or use the s:form tag theme attribute to override the default setting.

<s:form action="outbound.action" method="post" theme="xhtml">


来源:https://stackoverflow.com/questions/19120445/struts-2-textbox-label-is-not-displayed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!