How can I pass an object to a JSP tag?

A slightly different question that I looked for here: “How do you pass an object to a tag file?” Answer: Use the “type” attribute of the attribute directive: <%@ attribute name=”field” required=”true” type=”com.mycompany.MyClass” %> The type defaults to java.lang.String, so without it you’ll get an error if you try to access object fields saying that … Read more

Can not find the tag library descriptor of springframework

I know it’s an old question, but the tag library http://www.springframework.org/tags is provided by spring-webmvc package. With Maven it can be added to the project with the following lines to be added in the pom.xml <properties> <spring.version>3.0.6.RELEASE</spring.version> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> Without Maven, just add that jar to your classpath. In any … Read more

Use JS variable to set the src attribute for tag

Though CDATA works fine, using document.createElement is also a great choice.. Especially if you intend to append some value to a URL, say for cache busting.. <script type=”text/javascript”> var JSLink = “/Folder/sub_folder/version.js?version=” + Math.random(); var JSElement = document.createElement(‘script’); JSElement.src = JSLink; JSElement.onload = OnceLoaded; document.getElementsByTagName(‘head’)[0].appendChild(JSElement); function OnceLoaded() { // Once loaded.. load other JS or … Read more

How to programmatically resolve property placeholder in Spring

Since Spring 3.0.3 there is EmbeddedValueResolverAware which will work same way as mentioned by another post which uses appContext.getBeanFactory().resolveEmbeddedValue(“${prop}”) call. To solve the problem: Make your class to implement EmbeddedValueResolverAware interface and you will get resolver injected for you Then where you will be able to retrieve properties as demonstrated in a code snippet: String … Read more

Default value on JSP custom-tag attribute

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 old: <c:if test=”${empty title}” > <c:set var=”title” value=”Default title” /> </c:if>

techhipbettruvabetnorabahisbahis forumu