CSS: Select the last child from last row? - html
I'm trying to make a simple highlight when a user hovers the last date in the range date picker. I'm using a lib so I can't really change the inside things, but before I want to try to achieve this with pure CSS instead of jQuery. Maybe I'm just missing something. So the thing is that when user hovers a date it adds datepicker__month-day--hovering class and the :last-child and :last-of-type selectors selects all the last elements in the rows that they exists, but not the one that I'm currently hovering, how can I fix it?
This is my structure:
<tbody>
<tr class="datepicker__week-row">
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1672524000000" d="1" role="button" index="1" aria-label="Not available, Sunday, January 01, 2023" aria-disabled="true">1</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1672610400000" d="2" role="button" index="2" aria-label="Not available, Monday, January 02, 2023" aria-disabled="true">2</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1672696800000" d="3" role="button" index="3" aria-label="Not available, Tuesday, January 03, 2023" aria-disabled="true">3</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1672783200000" d="4" role="button" index="4" aria-label="Not available, Wednesday, January 04, 2023" aria-disabled="true">4</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1672869600000" d="5" role="button" index="5" aria-label="Not available, Thursday, January 05, 2023" aria-disabled="true">5</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1672956000000" d="6" role="button" index="6" aria-label="Not available, Friday, January 06, 2023" aria-disabled="true">6</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1673042400000" d="7" role="button" index="7" aria-label="Not available, Saturday, January 07, 2023" aria-disabled="true">7</td>
</tr>
<tr class="datepicker__week-row">
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1673128800000" d="1" role="button" index="8" aria-label="Not available, Sunday, January 08, 2023" aria-disabled="true">8</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1673215200000" d="2" role="button" index="9" aria-label="Not available, Monday, January 09, 2023" aria-disabled="true">9</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1673301600000" d="3" role="button" index="10" aria-label="Not available, Tuesday, January 10, 2023" aria-disabled="true">10</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1673388000000" d="4" role="button" index="11" aria-label="Not available, Wednesday, January 11, 2023" aria-disabled="true">11</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1673474400000" d="5" role="button" index="12" aria-label="Not available, Thursday, January 12, 2023" aria-disabled="true">12</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1673560800000" d="6" role="button" index="13" aria-label="Not available, Friday, January 13, 2023" aria-disabled="true">13</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1673647200000" d="7" role="button" index="14" aria-label="Not available, Saturday, January 14, 2023" aria-disabled="true">14</td>
</tr>
<tr class="datepicker__week-row">
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1673733600000" d="1" role="button" index="15" aria-label="Not available, Sunday, January 15, 2023" aria-disabled="true">15</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1673820000000" d="2" role="button" index="16" aria-label="Not available, Monday, January 16, 2023" aria-disabled="true">16</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid " daytype="visibleMonth" time="1673906400000" d="3" role="button" index="17" aria-label="Not available, Tuesday, January 17, 2023" aria-disabled="true">17</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--valid datepicker__month-day--today datepicker__month-day--checkin-only datepicker__month-day--first-day-selected datepicker__month-day--selected datepicker__month-day--tmp" daytype="visibleMonth" time="1673992800000" d="4" role="button" tabindex="0" index="18" aria-label="Selected as check-in date, Wednesday, January 18, 2023" aria-disabled="false">18</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid datepicker__month-day--tmp datepicker__month-day--hovering" daytype="visibleMonth" time="1674079200000" d="5" role="button" index="19" aria-label="Not available, Thursday, January 19, 2023" aria-disabled="true">19</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid datepicker__month-day--tmp datepicker__month-day--hovering" daytype="visibleMonth" time="1674165600000" d="6" role="button" index="20" aria-label="Not available, Friday, January 20, 2023" aria-disabled="true">20</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid datepicker__month-day--tmp datepicker__month-day--hovering" daytype="visibleMonth" time="1674252000000" d="7" role="button" index="21" aria-label="Not available, Saturday, January 21, 2023" aria-disabled="true">21</td>
</tr>
<tr class="datepicker__week-row">
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--invalid datepicker__month-day--tmp datepicker__month-day--hovering" daytype="visibleMonth" time="1674338400000" d="1" role="button" index="22" aria-label="Not available, Sunday, January 22, 2023" aria-disabled="true">22</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--valid datepicker__month-day--tmp datepicker__month-day--hovering" daytype="visibleMonth" time="1674424800000" d="2" role="button" index="23" aria-label="Choose Monday, January 23, 2023 as your check-out date" aria-disabled="false">23</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--valid datepicker__month-day--tmp datepicker__month-day--hovering" daytype="visibleMonth" time="1674511200000" d="3" role="button" index="24" aria-label="Choose Tuesday, January 24, 2023 as your check-out date" aria-disabled="false">24</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--valid datepicker__month-day--tmp datepicker__month-day--hovering" daytype="visibleMonth" time="1674597600000" d="4" role="button" index="25" aria-label="Choose Wednesday, January 25, 2023 as your check-out date" aria-disabled="false">25</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--valid datepicker__month-day--tmp datepicker__month-day--hovering" daytype="visibleMonth" time="1674684000000" d="5" role="button" index="26" aria-label="Choose Thursday, January 26, 2023 as your check-out date" aria-disabled="false">26</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--valid datepicker__month-day--tmp" daytype="visibleMonth" time="1674770400000" d="6" role="button" index="27" aria-label="Choose Friday, January 27, 2023 as your check-out date" aria-disabled="false">27</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--valid datepicker__month-day--tmp" daytype="visibleMonth" time="1674856800000" d="7" role="button" index="28" aria-label="Choose Saturday, January 28, 2023 as your check-out date" aria-disabled="false">28</td>
</tr>
<tr class="datepicker__week-row">
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--valid datepicker__month-day--tmp" daytype="visibleMonth" time="1674943200000" d="1" role="button" index="29" aria-label="Choose Sunday, January 29, 2023 as your check-out date" aria-disabled="false">29</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--valid datepicker__month-day--tmp" daytype="visibleMonth" time="1675029600000" d="2" role="button" index="30" aria-label="Choose Monday, January 30, 2023 as your check-out date" aria-disabled="false">30</td>
<td class="datepicker__month-day datepicker__month-day--visibleMonth datepicker__month-day--valid datepicker__month-day--tmp" daytype="visibleMonth" time="1675116000000" d="3" role="button" index="31" aria-label="Choose Tuesday, January 31, 2023 as your check-out date" aria-disabled="false">31</td>
<td class="datepicker__month-day datepicker__month-day--nextMonth datepicker__month-day--valid " daytype="nextMonth" time="1675202400000" d="4" role="button" index="0" aria-label="Choose Wednesday, February 01, 2023 as your check-out date" aria-disabled="false">1</td>
<td class="datepicker__month-day datepicker__month-day--nextMonth datepicker__month-day--valid " daytype="nextMonth" time="1675288800000" d="5" role="button" index="0" aria-label="Choose Thursday, February 02, 2023 as your check-out date" aria-disabled="false">2</td>
<td class="datepicker__month-day datepicker__month-day--nextMonth datepicker__month-day--valid " daytype="nextMonth" time="1675375200000" d="6" role="button" index="0" aria-label="Choose Friday, February 03, 2023 as your check-out date" aria-disabled="false">3</td>
<td class="datepicker__month-day datepicker__month-day--nextMonth datepicker__month-day--valid " daytype="nextMonth" time="1675461600000" d="7" role="button" index="0" aria-label="Choose Saturday, February 04, 2023 as your check-out date" aria-disabled="false">4</td>
</tr>
</tbody>
Related
Table row column validation in xslt
I have the below XML (table): <table-wrap id="tbl4" position="float"> <label>Table E3</label> <caption> <p></p> </caption> <alternatives> <graphic xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="EEMCS-01-2021-001110.tif"/> <table frame="hsides"> <colgroup> <col align="left"/> <col align="left"/> <col align="left"/> <col align="left"/> <col align="left"/> <col align="left"/> <col align="left"/> </colgroup> <thead> <tr> <th rowspan="2" align="left">1</th> <th colspan="4" align="center">2</th> <th rowspan="2" align="center">3</th> </tr> <tr> <th align="center">4</th> <th align="center">5</th> <th align="center">6</th> <th align="center">7</th> <th align="center">8</th> </tr> </thead> <tbody> <tr> <td>9</td> <td rowspan="2">10</td> <td>11</td> <td>12</td> <td>13</td> <td>14</td> <td rowspan="2">15</td> </tr> <tr> <td>16</td> <td>17</td> <td>18</td> <td>19</td> <td>20</td> </tr> <tr> <td>21</td> <td colspan="2">22</td> <td rowspan="2">23</td> <td colspan="2">24</td> <td>25</td> </tr> <tr> <td>26</td> <td>27</td> <td>28</td> <td>29</td> <td>30</td> <td>31</td> </tr> <tr> <td rowspan="2">32</td> <td colspan="2">33</td> <td>34</td> <td colspan="2">35</td> <td rowspan="2">36</td> </tr> <tr> <td>37</td> <td>38</td> <td>39</td> <td>40</td> <td>41</td> </tr> </tbody> </table> </alternatives> </table-wrap> I want to validate missing tr or td in each based on colspan and rowspan I would like to explain colspan and rowspan conditions: If colspan="2" in a td, it means two column entries are merged (spanned) so the count of td in that row will be decreased If rowspan="2" in a td, it means two-row entries are merged (spanned) so the count of td in next row will be decreased Is there is an additional column or row in the table I have to throw it as an error.
This is a tough problem, and you have to think quite carefully about edge cases, for example where a cell with colspan="2" partially overlaps a cell with rowspan="2" in the row above. There are many errors possible other than having an additional row or column and I assume you want to catch these too. There may be faster solutions, but I think the simplest is to have a first pass that creates a temporary data structure of the form <cell row="1" column="1"/> <cell row="1" column="2"/> <cell row="1" column="3"/> with one entry for each "real" (1 by 1) cell encountered, and then in a second pass check this data structure for discrepancies, e.g. no duplicates (overlapping cells) and no raggedness (max column for all rows must be the same, max row for all columns must be the same). You'll need to process the rows and columns in the input either using recursion, or if you can use XSLT 3.0 using xsl:iterate, so you can keep track of the current row and column number. Using xsl:iterate it will be something like this: <xsl:iterate select="tr"> <xsl:param name="currentRow" select="1"/> <xsl:iterate select="td"> <xsl:param name="currentCol" select="1"/> .... (see below) <xsl:next-iteration> <xsl:with-param name="currentCol" select="$currentCol + (#colspan, 1)[1]"/> </xsl:with-param> </xsl:next-iteration> </xsl:iterate> <xsl:next-iteration> <xsl:with-param name="currentRow" select="$currentRow + 1"/> </xsl:with-param> </xsl:next-iteration> </xsl:iterate> Then the processing for a td is fairly straightforward: you just do <xsl:for-each select="$currentRow to $currentRow + (#rowspan, 1)[1] - 1"> <xsl:variable name="row" select="."/> <xsl:for-each select="$currentCol to $currentCol + (#colspan, 1)[1] - 1"> <xsl:variable name="col" select="."/> <cell row="{$row}" col="{$col}"/> </xsl:for-each> </xsl:for-each> Hope this sketch is enough to give you some ideas.
How do I grab the text from two different nodes/elements simultaneously as I am iterating in xslt?
So I have the XML: <forecast> <area aac="NSW_FA001" description="New South Wales" type="region"> <forecast-period start-time-local="2020-04-13T09:08:07+10:00" end-time-local="2020-04-13T09:08:07+10:00" start-time-utc="2020-04-12T23:08:07Z" end-time-utc="2020-04-12T23:08:07Z"> <text type="warning_summary_footer">Details of warnings are available on the Bureau's website www.bom.gov.au, by telephone 1300-659-218* or through some TV and radio broadcasts.</text> <text type="product_footer">* Calls to 1300 numbers cost around 27.5c incl. GST, higher from mobiles or public phones.</text> </forecast-period> </area> <area aac="NSW_ME006" description="Canberra" type="metropolitan" parent-aac="NSW_FA001"> <forecast-period index="0" start-time-local="2020-04-13T00:00:00+10:00" end-time-local="2020-04-14T00:00:00+10:00" start-time-utc="2020-04-12T14:00:00Z" end-time-utc="2020-04-13T14:00:00Z"> <text type="forecast">Some high cloud, clearing by the afternoon. Light winds.</text> <text type="uv_alert">Sun protection 9:30am to 2:20pm, UV Index predicted to reach 5 [Moderate]</text> </forecast-period> <forecast-period index="1" start-time-local="2020-04-14T00:00:00+10:00" end-time-local="2020-04-15T00:00:00+10:00" start-time-utc="2020-04-13T14:00:00Z" end-time-utc="2020-04-14T14:00:00Z"> <text type="forecast">Areas of fog in the morning. Sunny day. Light winds becoming northwesterly 15 to 20 km/h in the early afternoon then becoming light in the late afternoon.</text> </forecast-period> <forecast-period index="2" start-time-local="2020-04-15T00:00:00+10:00" end-time-local="2020-04-16T00:00:00+10:00" start-time-utc="2020-04-14T14:00:00Z" end-time-utc="2020-04-15T14:00:00Z"> <text type="forecast">Patchy morning fog. Mostly sunny day. Light winds.</text> </forecast-period> <forecast-period index="3" start-time-local="2020-04-16T00:00:00+10:00" end-time-local="2020-04-17T00:00:00+10:00" start-time-utc="2020-04-15T14:00:00Z" end-time-utc="2020-04-16T14:00:00Z"> <text type="forecast">Partly cloudy. Slight (20%) chance of a shower. Winds northwesterly and light increasing to 20 to 25 km/h during the morning then increasing to 25 to 35 km/h during the day.</text> </forecast-period> <forecast-period index="4" start-time-local="2020-04-17T00:00:00+10:00" end-time-local="2020-04-18T00:00:00+10:00" start-time-utc="2020-04-16T14:00:00Z" end-time-utc="2020-04-17T14:00:00Z"> <text type="forecast">Mostly sunny. Winds northwesterly 15 to 20 km/h.</text> </forecast-period> <forecast-period index="5" start-time-local="2020-04-18T00:00:00+10:00" end-time-local="2020-04-19T00:00:00+10:00" start-time-utc="2020-04-17T14:00:00Z" end-time-utc="2020-04-18T14:00:00Z"> <text type="forecast">Mostly sunny. Slight (20%) chance of a shower. Light winds.</text> </forecast-period> <forecast-period index="6" start-time-local="2020-04-19T00:00:00+10:00" end-time-local="2020-04-20T00:00:00+10:00" start-time-utc="2020-04-18T14:00:00Z" end-time-utc="2020-04-19T14:00:00Z"> <text type="forecast">Partly cloudy. Slight (30%) chance of a shower. Light winds.</text> </forecast-period> </area> <area aac="NSW_PT027" description="Canberra" type="location" parent-aac="NSW_ME006"> <forecast-period index="0" start-time-local="2020-04-13T08:57:34+10:00" end-time-local="2020-04-14T00:00:00+10:00" start-time-utc="2020-04-12T22:57:34Z" end-time-utc="2020-04-13T14:00:00Z"> <element type="forecast_icon_code">3</element> <element type="air_temperature_maximum" units="Celsius">19</element> <text type="precis">Partly cloudy.</text> <text type="probability_of_precipitation">0%</text> </forecast-period> <forecast-period index="1" start-time-local="2020-04-14T00:00:00+10:00" end-time-local="2020-04-15T00:00:00+10:00" start-time-utc="2020-04-13T14:00:00Z" end-time-utc="2020-04-14T14:00:00Z"> <element type="forecast_icon_code">10</element> <element type="air_temperature_minimum" units="Celsius">4</element> <element type="air_temperature_maximum" units="Celsius">23</element> <text type="precis">Possible early fog then sunny.</text> <text type="probability_of_precipitation">0%</text> </forecast-period> <forecast-period index="2" start-time-local="2020-04-15T00:00:00+10:00" end-time-local="2020-04-16T00:00:00+10:00" start-time-utc="2020-04-14T14:00:00Z" end-time-utc="2020-04-15T14:00:00Z"> <element type="forecast_icon_code">3</element> <element type="air_temperature_minimum" units="Celsius">8</element> <element type="air_temperature_maximum" units="Celsius">25</element> <text type="precis">Mostly sunny.</text> <text type="probability_of_precipitation">0%</text> </forecast-period> <forecast-period index="3" start-time-local="2020-04-16T00:00:00+10:00" end-time-local="2020-04-17T00:00:00+10:00" start-time-utc="2020-04-15T14:00:00Z" end-time-utc="2020-04-16T14:00:00Z"> <element type="forecast_icon_code">3</element> <element type="air_temperature_minimum" units="Celsius">11</element> <element type="air_temperature_maximum" units="Celsius">25</element> <text type="precis">Partly cloudy.</text> <text type="probability_of_precipitation">20%</text> </forecast-period> <forecast-period index="4" start-time-local="2020-04-17T00:00:00+10:00" end-time-local="2020-04-18T00:00:00+10:00" start-time-utc="2020-04-16T14:00:00Z" end-time-utc="2020-04-17T14:00:00Z"> <element type="forecast_icon_code">3</element> <element type="air_temperature_minimum" units="Celsius">11</element> <element type="air_temperature_maximum" units="Celsius">20</element> <text type="precis">Mostly sunny.</text> <text type="probability_of_precipitation">10%</text> </forecast-period> <forecast-period index="5" start-time-local="2020-04-18T00:00:00+10:00" end-time-local="2020-04-19T00:00:00+10:00" start-time-utc="2020-04-17T14:00:00Z" end-time-utc="2020-04-18T14:00:00Z"> <element type="forecast_icon_code">3</element> <element type="air_temperature_minimum" units="Celsius">4</element> <element type="air_temperature_maximum" units="Celsius">19</element> <text type="precis">Mostly sunny.</text> <text type="probability_of_precipitation">20%</text> </forecast-period> <forecast-period index="6" start-time-local="2020-04-19T00:00:00+10:00" end-time-local="2020-04-20T00:00:00+10:00" start-time-utc="2020-04-18T14:00:00Z" end-time-utc="2020-04-19T14:00:00Z"> <element type="forecast_icon_code">3</element> <element type="precipitation_range">0 to 0.4 mm</element> <element type="air_temperature_minimum" units="Celsius">8</element> <element type="air_temperature_maximum" units="Celsius">19</element> <text type="precis">Partly cloudy.</text> <text type="probability_of_precipitation">30%</text> </forecast-period> </area> <area aac="NSW_PT146" description="Tuggeranong" type="location" parent-aac="NSW_ME006"> <forecast-period index="0" start-time-local="2020-04-13T08:57:34+10:00" end-time-local="2020-04-14T00:00:00+10:00" start-time-utc="2020-04-12T22:57:34Z" end-time-utc="2020-04-13T14:00:00Z"> <element type="air_temperature_maximum" units="Celsius">19</element> </forecast-period> </area> </forecast> To get the text: Forecast for the rest of Monday April 13 Some high cloud, clearing by the afternoon. Light winds. Forecast for the rest of Tuesday April 14 Areas of fog in the morning. Sunny day. Light winds becoming northwesterly 15 to 20 km/h in the early afternoon then becoming light in the late afternoon. Forecast for the rest of Wednesday April 15 Patchy morning fog. Mostly sunny day. Light winds. .... etc I used: <xsl:variable name ="cb" select="document('cb123.xml')"/> <xsl:variable name = "canberra_date" select = "$cb/forecast/area[#aac='NSW_ME006']/forecast-period"/> <b>Canberra Weather</b> <br></br> <xsl:for-each select='$canberra_date'> <xsl:text>Forecast for the rest of </xsl:text><xsl:value-of select="format-dateTime(#start-time-local, '[F] [MNn] [D1]', 'en', (), ()) "/> <br></br> <xsl:value-of select="text[#type='forecast']"/> <br></br> </xsl:for-each> Q1. How would I be able to get the text above and write it to a html as well as the temperatures inside the nodes: /forecast/area[#aac='NSW_PT027']/forecast-period/element[#type='air_temperature_maximum'] and /forecast/area[#aac='NSW_PT027']/forecast-period/element[#type='air_temperature_minimum'] Q2. How would I do it so that it skips the first text in this loop? i.e. I don't want the "Forecast for the rest of Monday April 13, only starting at Tuesday April 14 as well as the corresponding temperatures? Desired output: > Forecast for Tuesday 14 April Areas of fog in the morning. Sunny day. > Light winds becoming northwesterly 15 to 20 km/h in the early > afternoon then becoming light in the late afternoon. Min 4 Max 23 > > Forecast for Wednesday 15 April Patchy morning fog. Mostly sunny day. > Light winds. Min 8 Max 25 .... Something like this.. thanks!
Here's a way this could be done. Adapt the layout to what you need. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"> <xsl:output method="html" indent="yes"/> <xsl:template match="/"> <html> <head> <title>Weather Forecast</title> </head> <body> <b>Canberra Weather</b> <br/> <xsl:for-each select="forecast/area[#aac='NSW_ME006']/forecast-period[position()!=1]"> <!-- Skip first forecast-period --> <xsl:variable name="currentF" select="."/> <xsl:text>Forecast for the rest of </xsl:text><xsl:value-of select="format-dateTime(#start-time-local, '[F] [MNn] [D1]', 'en', (), ()) "/> <xsl:value-of select="text[#type='forecast']"/> <br/> Min <xsl:value-of select="//area[#parent-aac=$currentF/../#aac]/forecast-period[#start-time-local=$currentF/#start-time-local]/element[#type='air_temperature_minimum']"/> <br/> Max <xsl:value-of select="//area[#parent-aac=$currentF/../#aac]/forecast-period[#start-time-local=$currentF/#start-time-local]/element[#type='air_temperature_maximum']"/> <br/><br/> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet> See it working here : https://xsltfiddle.liberty-development.net/gVhDDzf
Getting java.lang.NumberFormatException: For input string: "aNumber"
I want to print a list of Users on JSP. This list getting captured in controller method correctly but it is not passed on to the JSP page. Controller Method Code - #PostMapping("/list") public String listCandidates(#RequestParam("list") String roType, Model theModel) { if(roType.equalsIgnoreCase("qualZRO1")) { List qList = adgService.getQualCandListZRO1(); theModel.addAttribute("candlist", qList); return "adgSummary"; } } JSP Page - I want to display the below information about candidates in a table form in JSP page. Refer below stacktrace which shows that there is NumberFormatException error with "aNumber". <%# taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%# taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix= "fmt" %> <!DOCTYPE html> <html><head> <title></title> <!-- reference our style sheet --> <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/style.css" /> </head> <body> <div id="wrapper"> <div id="header"> <div style="text-align:center"> <h2>SRS</h2> </div> </div> </div> <div> <!-- viewing the details --> Z1 Qualified Candidates: <c:out value="${qualCandZ1}"/> Z1 Selected Candidates: <c:out value="${selCandZ1}"/> I1 Qualified Candidates: <c:out value="${qualCandI1}"/> I1 Selected Candidates: <c:out value="${selCandI1}"/> </div> <div id="container"> <div id="content"> <!-- add a search box --> <form:form name="list" action="list" method="POST"> <input type="hidden" name="list" /> <input type="submit" value="qualZRO1" name="dayOne" class="add-button" onclick="{document.list.list.value=this.value;}" /> <input type="submit" value="selZRO1" name="dayTwo" class="add-button" onclick="{document.list.list.value=this.value;}" /> <input type="submit" value="qualIRO1" name="dayTwo" class="add-button" onclick="{document.list.list.value=this.value;}" /> <input type="submit" value="selIRO1" name="dayTwo" class="add-button" onclick="{document.list.list.value=this.value;}" /> </form:form> <table><tr> <th>A No</th> <th>First Name</th> <th>Middle Name</th> <th>Last Name</th> <th>RO</th> <th>AType</th> <th>Score</th> <th>Result</th> <th>Selected</th> </tr> <!-- loop over and print our candidates--> <c:forEach var="tempCustomer" items="${candlist}"> <tr> <td> ${tempCustomer.aNumber} </td> <td> ${tempCustomer.firstName} </td> <td> ${tempCustomer.middleName} </td> <td> ${tempCustomer.lastName} </td> <td> ${tempCustomer.ro} </td> <td> ${tempCustomer.aType} </td> <td> ${tempCustomer.score} </td> <td> ${tempCustomer.result} </td> <td> ${tempCustomer.selected} </td> </tr></c:forEach></table></div></div></body></html> Stacktrace from Console window which shows NumberFormatException error - Apr 25, 2018 9:42:11 AM org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet [jsp] threw exception java.lang.NumberFormatException: For input string: "aNumber" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at javax.el.ArrayELResolver.coerce(ArrayELResolver.java:144) at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:61) at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110) at org.apache.el.parser.AstValue.getValue(AstValue.java:169) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184) at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:702) at org.apache.jsp.WEB_002dINF.view.adgSummary_jsp._jspx_meth_c_005fforEach_005f0(adgSummary_jsp.java:426) at org.apache.jsp.WEB_002dINF.view.adgSummary_jsp._jspService(adgSummary_jsp.java:214) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:170) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:314) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881) at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:407) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) Apr 25, 2018 9:42:11 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/SRS-ADGDELHI] threw exception [An exception occurred processing [WEB-INF/view/adgSummary.jsp] at line [71] 68: <c:forEach var="tempCustomer" items="${candlist}"> 69: 70: <tr> 71: <td> ${tempCustomer.aNumber} </td> 72: <td> ${tempCustomer.firstName} </td> 73: <td> ${tempCustomer.middleName} </td> 74: <td> ${tempCustomer.lastName} </td>
Try changing the List qList to List<your_class> qlist. Follow this link for additional info : ${employee.id} from List in JSP throws java.lang.NumberFormatException: For input string: "id"
You can change the List qlist to generic. You can change your code like List<classname> qList = adgService.getQualCandListZRO1(); insted of List qList = adgService.getQualCandListZRO1();
jsp page not displaying table column headers
I currently am making a table which has 8 columns. To start, I check if the value is null, if not null I write out a column title for the column (ex: "First Name:"). Next, I cycle through a list and populate each column with the appropriate value if it is not null. My issue is that the column headers (in between the comments in the code below) does not print while the actual data in the table does print. Can anyone help me? <table style="width: 100%"> <c:choose> <c:when test="${empty serviceRequests}"> </c:when> <c:otherwise> <tr> //DOES NOT PRINT STARTING FROM HERE <td><c:choose> <c:when test="${empty serviceRequestData['ID']}"></c:when> <c:otherwise> <u>ID:</u> </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['FN_Contact']}"></c:when> <c:otherwise> <u>First Name:</u> </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['LN_Contact']}"></c:when> <c:otherwise> <u>Last Name:</u> </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['Email']}"></c:when> <c:otherwise> <u>Email:</u> </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['FN_Reporter']}"></c:when> <c:otherwise> <u>Reporter First Name:</u> </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['LN_Reporter']}"></c:when> <c:otherwise> <u>Reporter Last Name:</u> </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['Company']}"></c:when> <c:otherwise> <u>Company:</u> </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['Notes']}"></c:when> <c:otherwise> <u>Notes:</u> </c:otherwise> </c:choose></td> </tr> //DOES NOT PRINT ENDING HERE <c:forEach var="serviceRequestData" items="${serviceRequests}"> <tr> <td><c:choose> <c:when test="${empty serviceRequestData['ID']}"> Null </c:when> <c:otherwise> ${serviceRequestData['ID']} </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['FN_Contact']}"> Null </c:when> <c:otherwise> ${serviceRequestData['FN_Contact']} </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['LN_Contact']}"> Null </c:when> <c:otherwise> ${serviceRequestData['LN_Contact']} </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['Email']}"> Null </c:when> <c:otherwise> ${serviceRequestData['Email']} </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['FN_Reporter']}"> Null </c:when> <c:otherwise> ${serviceRequestData['FN_Reporter']} </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['LN_Reporter']}"> Null </c:when> <c:otherwise> ${serviceRequestData['LN_Reporter']} </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['Company']}"> Null </c:when> <c:otherwise> ${serviceRequestData['Company']} </c:otherwise> </c:choose></td> <td><c:choose> <c:when test="${empty serviceRequestData['Notes']}"> Null </c:when> <c:otherwise> ${serviceRequestData['Notes']} </c:otherwise> </c:choose></td> </tr> </c:forEach> </c:otherwise> </c:choose> </table>
The variable you are trying to access in the table headers isn't defined until the <c:forEach> used to iterate over the data rows. This should work: <table style="width: 100%"> <c:choose> <c:when test="${empty serviceRequests}"></c:when> <c:otherwise> <tr> <td> <u>ID:</u> </td> <td> <u>First Name:</u> </td> <td> <u>Last Name:</u> </td> <td> <u>Email:</u> </td> <td> <u>Reporter First Name:</u> </td> <td> <u>Reporter Last Name:</u> </td> <td> <u>Company:</u> </td> <td> <u>Notes:</u> </td> </tr> <c:forEach var="serviceRequestData" items="${serviceRequests}"> ... </c:forEach> </c:otherwise> </c:choose> </table> Of course you'll need to figure out what logic, (if any) that you want to use to wrap the header values.
How to use placeholder HTML with Spring <form:input> tag on jsp page
I use this line of code on jsp page: <tr> <td> <form:label path="formDescription.daySchedule"> <spring:message code="label.input.daySchedule"/> </form:label> </td> <td> <form:input path="formDescription.daySchedule" placeholder="<spring:message code="label.input.dayScheduleExample"/>" /> </td> <td><form:errors path="formDescription.daySchedule"/> </td> </tr> I want to use html placeholder tag to render example in input field, but the problem that I want to render it on different languages. But it gives me an error when I try to render a page: Aug 04, 2013 6:54:11 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [appServlet] in context with path [/web] threw exception [/WEB-INF/views/input.jsp(103,258) equal symbol expected] with root cause org.apache.jasper.JasperException: /WEB-INF/views/input.jsp(103,258) equal symbol expected at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41) at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407) at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88) at org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:217) at org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:162) at org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:153) at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1236) at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1450) at org.apache.jasper.compiler.Parser.parseBody(Parser.java:1662) at org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:1002) at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1274) at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1450) at org.apache.jasper.compiler.Parser.parse(Parser.java:138) at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:239) at org.apache.jasper.compiler.ParserController.parse(ParserController.java:102) at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:197) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:372) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:352) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:339) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:263) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)
I think that you can't use a tag inside an other tag. Try with the JSP expression language (EL) : <spring:message code="label.input.dayScheduleExample" var="dayScheduleExample"/> <tr> <td> <form:label path="formDescription.daySchedule"> <spring:message code="label.input.daySchedule"/> </form:label> </td> <td> <form:input path="formDescription.daySchedule" placeholder="${dayScheduleExample}" /> </td> <td><form:errors path="formDescription.daySchedule"/> </td> </tr>
Works for me, I've added the attribute placeholder with javascript / jquery as below : $("#myID").attr('placeholder', '<spring:message code="myCode"/>');
I think you asp markup is wrong here: placeholder="<spring:message code="label.input.dayScheduleExample"/>" Replace it with: placeholder='<spring:message code="label.input.dayScheduleExample"/>' Starting from Spring 3 form tags support dynamic attributes.