jsp-tags

Where do I put the .tld file so that the resulting JAR file built with maven2 is properly packaged?

穿精又带淫゛_ 提交于 2019-12-04 05:04:08
I currently have the following directory structure for my code: src |-- main | `-- java | `-- com | `-- upthescala | `-- tags | `-- ViewProtectTag.java |-- test |-- pom.xml |-- .project |-- .classpath `-- .hgignore I want to include a tld file for my JSP tag, and I'm not sure where to package it. My initial thought is to add a src/main/resources directory and put META-INF/viewprotect.tld in there. My initial thought is to add a src/main/resources directory and put META-INF/viewprotect.tld in there And that's a good initial thought. 来源: https://stackoverflow.com/questions/3105539/where-do-i-put

Change Struts 2, i18n classes behavior when key is not found

半世苍凉 提交于 2019-12-04 04:08:13
问题 We used getText in actions, setMessageKey in validators and <s:text> in jsp files for an i18n application. When Struts 2 could not find a key in resource bundles it returns the key itself. For example form.transfer.confirm . How can we change this behavior in the way that instead of the key itself Struts2 returns empty string. 回答1: You need to create custom implementation of TextProvider and override getText methods in it. 1) Create class (e.g. EmptyDefaultTextProvider ) extending one of

Equivalent to the deprecated <sec:authorize> ifNotGranted attribute

落爺英雄遲暮 提交于 2019-12-04 03:34:44
I would like to prevent an image having a link if a user does NOT have a certain role. e.g. <sec:authorize ifNotGranted="ROLE_ACCOUNTS" ><img src="someimage.jpg"/></sec:authorize> <sec:authorize ifAllGranted="ROLE_ACCOUNTS" ><a href="somelink.htm"><img src="someimage.jpg"/></a></sec:authorize> However ifNotGranted and ifAllGranted are now deprecated in favour of the access expression. I can see that ifAllGranted can be replicated with: <sec:authorize access="hasRole('ROLE_ACCOUNTS')"><a href="somelink.htm"><img src="someimage.jpg"/></a></sec:authorize> But how can ifNotGranted be replicated

JSP Tag Files in subdirectories, using a single taglib prefix. Is that possible?

泪湿孤枕 提交于 2019-12-04 02:34:15
I currently have my .tag files declared with: <%@taglib prefix="t" tagdir="/WEB-INF/tags" %> Example of the path of a tag file : /WEB-INF/tags/test.tag And I use them like so : <t:test oneAttributeKey="oneAttributeValue"> some content... </t:test> My problem : I don't want to put all my tag files in one single folder, "/WEB-INF/tags". I would prefere to have them in different subdirectories : /WEB-INF/tags/users/ /WEB-INF/tags/widgetsA/ /WEB-INF/tags/widgetsB/ (...) Is this possible, without creating a different taglib prefix for each and everyone of them ? Example of what I'd like to avoid :

Effective way to handle singular/plural word based on some collection size [closed]

拈花ヽ惹草 提交于 2019-12-03 23:16:24
There are many instances in my work projects where I need to display the size of some collection in a sentence. For example, if the collection's size is 5, it will say "5 users". If it is size of 1 or 0, it will say "1 user" or "0 user". Right now, I'm doing it with if-else statements to determine whether to print the "s" or not, which is tedious. I'm wondering if there's an open source JSP custom tag library that allows me to accomplish this. I know I can write one myself... basically, it will have 2 parameters like this: <lib:display word="user" collection="userList" /> . Depending on the

How to implement a “include” jsp tag?

大憨熊 提交于 2019-12-03 22:11:48
I need to define a jsp tag which named "include". It should be used as: <cms:include page="/aaa.jsp" /> It has an attribute page which points to another jsp, and it will include the content of that jsp and render it. Is there any existing tag lib can do this? Or please give me some advises of implementing it, thanks! UPDATE From Ramesh PVK's answer, I know there is a standard <jsp:include> fit my need. But per my project's requirements, I can use the name jsp:include , but cms:include . I've already defined some other tags which have prefix cms , and the include one should have the same prefix

<%@ page pageEncoding=“UTF-8”%> ignored when included from another jsp

只愿长相守 提交于 2019-12-03 16:59:14
问题 I have code (now in github) like : my.jsp (a generic jsp - all my jspS follow this pattern more or less) : <%@ include file="include/top.jsp" %> <title>THE TITLE</title> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ include file="include/head.jsp" %> <%@ include file="include/no_menu.jsp" %> CONTENT <%@ include file="include/bottom.jsp" %> where : top.jsp : <%@ page session="false"%> <%@ include file="tag_libs.jsp"%> <!DOCTYPE html PUBLIC "-//W3C/

What does the dollar curly brackets ${} mean in JSP?

杀马特。学长 韩版系。学妹 提交于 2019-12-03 15:08:18
问题 What does ${} means in JSP? For example, <c:if test="${!empty cookie.lang}"> <fmt:setLocale value="${cookie.lang.value}" /> </c:if> 回答1: its an El expression basically it outputs the value that result from evaluating the expression, to put it simply, it allows you to access the values of the properties of your java beans using "dots" instead of using getters and setters, using it you can access instances of beans that can be in session,request, or page scope 回答2: It is Expression Language.

Mapping an exception to 404 page while using Spring Security taglibs

吃可爱长大的小学妹 提交于 2019-12-03 13:15:45
When mapping an Exception to 404 page, the Spring Security tags can't find the authentication information from the security context. With a "real" 404 the authentication is found. My web.xml: <error-page> <exception-type>com.example.NotFoundException</exception-type> <location>/app/404</location> </error-page> <error-page> <error-code>404</error-code> <location>/app/404</location> </error-page> On the JSP I have: <sec:authorize access="hasRole('ROLE_USER')"> <%-- Show navigation links --%> </sec:authorize> <sec:authorize access="isAnonymous()"> <%-- Show login form --%> </sec:authorize> The

how to load CSS file into jsp

烈酒焚心 提交于 2019-12-03 11:43:18
问题 I created a jsp page as follows: <%@ page contentType="text/css" %> <html> <head> <title>Login page</title> <link href="/css/loginstyle.css" rel="stylesheet" type="text/css"> </head> <body> <h1> India welfare</h1> <p> welcome </p> </body> </html> and named it as login.jsp and i also created a css file called loginstyle.css and the code of the .css file is as follows: body { background-color:#d0e4fe; } h1 { color:orange; text-align:center; } p { font-family:"Times New Roman"; font-size:20px; }