jsp-tags

<c:foreach jsp iterate over list

混江龙づ霸主 提交于 2019-11-27 18:24:46
问题 I have searched several examples, still have not get. I am passing an List of GOOD object from controller into jsp pages. trying to loop over the list object, but its showing only one element repeatedly. should I use beans? If yes, could you provide more specific example for my case. <c:if test="${not empty listGood}"> <c:forEach var="ob" varStatus="status" items="${listGood}"> <tr> <td><c:out value="${ob.name}"/></td> <td><c:out value="${ob.measure}"/></td> <td><c:out value="${ob.quantity}"/

How to write tag in my spring project?

痴心易碎 提交于 2019-11-27 16:31:11
问题 I want to write my tag (extends TagSupport ) in my spring framework. In my tag class, will use some service which should auto inject by spring. But I always get null, seems spring can't inject service instance in my tag class. The code is like the following: public class FetchTagNameTag extends TagSupport { @Autowired private TaskService taskService; ... taskService is always null. How can I resolve this? Thanks. 回答1: JSP tag objects are not managed by Spring, they are managed by the servlet

Spring MVC form:select Tag, multiple selections not binding correctly?

折月煮酒 提交于 2019-11-27 14:11:35
问题 I am trying to create a form to edit an existing database row. I am using the Spring MVC form tag to auto bind the html to a form backing object. The row has a many to many relationship with another table, which I am trying to represent with a multiple select box using the form:select tag; <form:select path="rules"> <form:options items="${bundle.rules}" itemValue="name" itemLabel="name"/> </form:select> I am using Hibernate for persistence so the relationship is represent as a HashSet inside

Default value on JSP custom-tag attribute

丶灬走出姿态 提交于 2019-11-27 10:42:43
问题 When defining an attribute for a custom JSP tag, is it possible to specify a default value? The attribute directive doesn't have a default value attribute. Currently I'm making do with: <%@ attribute name="myAttr" required="false" type="java.lang.String" %> <c:if test="${empty myAttr}" > <c:set var="myAttr" value="defaultValue" /> </c:if> Is there a better way? 回答1: There is a better way: <c:set var="title" value="${(empty title) ? 'Default title' : title}" /> No need for custom tag in Java

Can not find the tag library descriptor of springframework

十年热恋 提交于 2019-11-27 04:29:20
I'm trying to follow the example of spring JPetStore but I get an error in the JSP pages in the line that references the lib tag spring: Can not find the tag library descriptor for "http://www.springframework.org/tags" <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> What is the URL of this library? Is there any way to avoid the direct dependence on this URL? Thanks in advance Adalarasan Sachithanantham Download the Spring dependency jar Place it to the lib folder path is /WEB-INF/lib/spring.jar Then open the web.xml and the sample code is: <taglib> <taglib-uri>/WEB-INF

How to programmatically resolve property placeholder in Spring

懵懂的女人 提交于 2019-11-27 00:35:07
问题 I currently work on a web application based on Spring 3.1.0.M1, annotations based, and I have a problem with resolving property placeholders in one specific place of my application. Here is the story. 1) In my web application context (loaded by DispatcherServlet), i have mvc-config.xml: <!-- Handles HTTP GET requests for /resources/version/** --> <resources mapping="/${app.resources.path}/**" location="/static/" cache-period="31556926"/> ... <!-- Web properties --> <context:property

Struts2 .action extension causing CSS, JavaScript and Struts Dojo to break

风格不统一 提交于 2019-11-26 21:02:09
We have been running on Struts 2.1.8 for some time and all Struts actions have been working as expected, i.e. href's to the Struts actions are rendered with the action name with no extension. Here is the JSP code that set's up the links: <ul id="top_menu"> <li id="itemHome" class="active"><s:a action="viewHome">Home</s:a></li> <li><s:a action="viewSearch">Search</s:a></li> <li><s:a action="viewBookMarks">My Bookmarks</s:a></li> <li><s:a action="viewSupport">Support</s:a></li> </ul> The links rendered correctly to http://localhost/viewHome , http://localhost/viewSearch , etc. under 2.1.8 We

How to inject spring beans into a jsp 2.0 SimpleTag?

倖福魔咒の 提交于 2019-11-26 16:44:19
问题 Currently my jsp 2.0 tags that need spring beans use this code: ac = WebApplicationContextUtils.getWebApplicationContext( servletContext); ac.getBeansOfType(MyRequestedClass.class); The I just get the first matching bean. This code works fine, but has the undesired drawback that I spend about half my page rendering time looking up spring beans, since this happens every time a tag is invoked. I was thinking maybe to put the bean into application scope or at least session scope. But what's

What&#39;s the difference between including files with JSP include directive, JSP include action and using JSP Tag Files?

喜夏-厌秋 提交于 2019-11-26 00:31:44
问题 It seems that there are two methods for templating with JSP. Including files with one of these statements <%@ include file=\"foo.html\" %> <jsp:include page=\"foo.html\" /> or using JSP tag files // Save this as mytag.tag <%@ tag description=\"Description\" pageEncoding=\"UTF-8\"%> <html> <head> </head> <body> <jsp:doBody/> </body> </html> And in another JSP page call it with <%@ taglib prefix=\"t\" tagdir=\"/WEB-INF/tags\" %> <t:mytag> <h1>Hello World</h1> </t:mytag> So which method should I