jstl

Values not displayed in jsp

帅比萌擦擦* 提交于 2020-01-01 19:16:17
问题 I am new to spring framework and using jstl. I have a problem in displaying my data on jsp file. Here is my code Controller @RequestMapping(method = RequestMethod.GET, value = "/test") public ModelAndView getTest(HttpServletRequest request) { List<Place> places = PlacesService.search(types, 48.137048, 11.57538599, 10000); for(Place place:places){ System.out.println("Name: " + place.getName()); System.out.println("Rating: " + place.getRating()); System.out.println("Categories: " + place

Backing bean String[] access in JSF

二次信任 提交于 2020-01-01 18:22:22
问题 First, apologies if you've been involved with my recent questions. As this isn't a discussion forum, and comments are limited, my last hope is to ask a specific question with actual code in the hope that somehow I can reach the bottom of my problem. OK. I've a backing bean called PrismBacking with this pertinent code: public class PrismBacking { private ArrayList dataList; public ArrayList<String> getFeedDataList() { XMLHandler xmlh = new XMLHandler(); dataList = new ArrayList(); Document doc

How to check in JSTL whether object is String or Collection?

旧时模样 提交于 2020-01-01 09:44:05
问题 I'm using JSTL and want to check whether an object is a String or a Collection. fn:length returns results on both types (stringsize or number of elements in the collection). <c:if test="${fn:length(item)>1}"> <c:out value="${fn:length(item)} " /> </c:if> How can I determine which one I've got? 回答1: You could look at the class name. For example: <c:if test="${item.class.simpleName == 'String'}"> <!-- it's a String! --> </c:if> 回答2: item.class lead to errors when using with tomcat 7. For me

How to check in JSTL whether object is String or Collection?

淺唱寂寞╮ 提交于 2020-01-01 09:44:03
问题 I'm using JSTL and want to check whether an object is a String or a Collection. fn:length returns results on both types (stringsize or number of elements in the collection). <c:if test="${fn:length(item)>1}"> <c:out value="${fn:length(item)} " /> </c:if> How can I determine which one I've got? 回答1: You could look at the class name. For example: <c:if test="${item.class.simpleName == 'String'}"> <!-- it's a String! --> </c:if> 回答2: item.class lead to errors when using with tomcat 7. For me

Xhtml pages and HttpSession test , no jstl?

一世执手 提交于 2020-01-01 07:16:12
问题 I have a dynamic web application in Java EE with JSF, Facelets, Richfaces. My pages are all xhtml pages. So JSTL isn't working in it. For my account pages and all other private pages to be reachable, I want to test if the user got connected, so if the attribute session in HttpSession is not null. If it's null, the user gets redirected in the welcome page. I tried in my xhtml page : <jstl:if test="${sessionScope['session']==null}"> <jstl redirect...> </jstl:if>--> but as it's not jsp page it

new line doesn't appear when using c out tag

戏子无情 提交于 2020-01-01 05:33:32
问题 I appended "\n" to the String and when using s tag textarea, the newline has been appended and data are shown line by line. But when I use c out tag, data are shown in one line. How can I show line by line using with c out tag? StringBuffer sb = new StringBuffer(); for (MyBean bean : beanList) { sb.append((bean.getName()); sb.append("\n"); } return sb.toString(); JSP <c:out value="${myData}"/> 回答1: JSP produces HTML. In HTML, new lines are to be represented by the <br> element, not by the

Is it possible to compare 2 variables in Struts IF statement when one of variables is from <c:foreach>?

佐手、 提交于 2019-12-31 05:47:05
问题 I'm trying to compare attribute value with some value passed from <c:foreach> to <s:if> and it always is false (even though it shouldn't). <c:forEach items="${liveBuyRequestsId}" var="item"> <s:if test="%{#attr.documentRow.buyRequest.id == item}"> The value of item is Long, same should be for id. What am I doing wrong? 来源: https://stackoverflow.com/questions/57296753/is-it-possible-to-compare-2-variables-in-struts-if-statement-when-one-of-variabl

Sending & in query String

一曲冷凌霜 提交于 2019-12-31 05:36:13
问题 From first.jsp I am sending some parameters to result.jsp as - <a href="result.jsp?itemId=${itemId}&itemName=${item.itemName}&itemCode=${item.itemCode}')">Show Items</a> Here ${item.itemName} can have values like "food & stationary" . When item name contains an "&", I am not able to get whole value on result page, its printing only "food" . Is there any way (in JSTL or any) so that I can encode "&". I know if I would convert "&" to "%26" then this would correct. 回答1: Use JSTL's c:url and c

java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;

匆匆过客 提交于 2019-12-31 04:22:57
问题 I am trying to set a variable that I will refer to in a custom JSP tag, so I have something like this in my JSP: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="path" value="test"/> However, I am getting this error when The JSP runs: java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext; at org.apache.taglibs.standard.tag.common.core.SetSupport.doEndTag(SetSupport.java:140) I am running Tomcat 5.5, and Java 1.5, with JSTL 1

Using <s:iterator> to populate a dynamic arraylist over multiple columns

女生的网名这么多〃 提交于 2019-12-31 03:49:26
问题 I am trying to populate an ArrayList over multiple table columns, this was originally done using Scriptlets on our old page but I know that the practice is frowned upon now. And I am having trouble translating it over using struts tags. I want the table to end up like this, Checkbox 1 Name 1 Checkbox 2 Name 2 Checkbox 3 Name 3 Checkbox 4 Name 4 etc.... This is the original scriptlet code: <% for (int j=0; j < getDocumentList().length; j++) { setPacket(j); setStringIndex(Integer.toString(j));