jsp-tags

extending spring form tag library attributes

别等时光非礼了梦想. 提交于 2019-11-29 10:25:04
问题 I'm using Spring's form tag library in a Spring MVC application that I am developing. The company I am working for has implemented some company-wide policies based on the definition of custom attributes for certain tags. For instance, by default (though the inclusion of a standard javascript file) all tags have their values automatically converted to upper case. In order to disable this one would define their tag with a custom attribute in the following way: <input type="text" uppercase=

Why is <taglib> giving me a problem in my web.xml?

纵饮孤独 提交于 2019-11-29 09:06:34
I have this web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>jsp-tags</display-name> <taglib> <taglib-uri>mytags</taglib-uri> <taglib-location>/WEB-INF/mytaglib.tld</taglib-location> </taglib> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome

<c:foreach jsp iterate over list

六月ゝ 毕业季﹏ 提交于 2019-11-29 04:29:14
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}"/></td> <td><c:out value="${ob.price}"/></td> </tr> </c:forEach> </c:if> Update Here is the controller:

How to write tag in my spring project?

可紊 提交于 2019-11-29 02:18:10
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. JSP tag objects are not managed by Spring, they are managed by the servlet container. As a result, you cannot autowire stuff into your tags. If you need to get hold of beans from the

How to access request in JspTags?

我与影子孤独终老i 提交于 2019-11-29 01:24:55
I want to call request.getContextPath() inside a JSP tag which extends SimpleTagSupport , is there any way to do it? First get the PageContext by the inherited SimpleTagSupport#getJspContext() and then get the HttpServletRequest by PageContext#getRequest() . PageContext pageContext = (PageContext) getJspContext(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); 来源: https://stackoverflow.com/questions/2098796/how-to-access-request-in-jsptags

Using the POST Method with HTML Anchor Tags

馋奶兔 提交于 2019-11-28 22:26:38
问题 I am certain the answer will be 'NO', but I wanted to ask anyway just incase I have missed something. Everyone knows that one pass data to a page in an anchor tag by using the GET method: What I am wondering is if there was a way to do the same thing, but use the POST Method instead? My purpose in doing so is to keep the URLs the user sees clean by not putting anything in them that they do not need to see. This has nothing to do with security concerns as I already know there would be ways to

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

扶醉桌前 提交于 2019-11-28 22:04:04
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 the Bundle pojo. private Set<Rule> rules = new HashSet<Rule>(0); Without the selection box on the page,

Default value on JSP custom-tag attribute

筅森魡賤 提交于 2019-11-28 17:44:53
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? G. Demecki There is a better way: <c:set var="title" value="${(empty title) ? 'Default title' : title}" /> No need for custom tag in Java nor tld. Just plain JSP EL and conditional operator. In my opinion it is shorter and cleaner than

Struts select tag localization implementation

时光总嘲笑我的痴心妄想 提交于 2019-11-28 14:05:42
Following is the Struts code for the <s:select> tag in my JSP file. <s:select name="choice" list="{'Add to My List','Remove from My List','Activate','Deactivate','Print'}" theme="xhtml" cssClass="text" required="false"/> I need to localize the list elements to French as shown below. <s:select name="choice" list="{'Ajouter à Ma liste','Enlever de ma liste','Activer','Désactiver','Imprimer'}" theme="xhtml" cssClass="text" required="false"/> How can I achieve this using the Internationalization and localization properties files. Regards At your properties file place that equations: addTolist =

Use JS variable to set the src attribute for <script> tag

人走茶凉 提交于 2019-11-28 11:52:55
I want to use a javascript variable as a 'src' attribute for another tag on the same jsp. <script> var link = mylink // the link is generated based on some code </script> I want to create this new element as shown below. <script src="mylink"> </script> On searching various forums, I have tried using the following options but they don't seem to work. I want this thing to work on all major browsers. Put this code in the first element. var script = document.createElement("script"); script.type = "text/javascript"; script.src = "path/to/somelink"; document.body.appendChild(script); Use document