简体   繁体   中英

How do I get a dynamic href tag with JSP with a value from java class

I'm able to get the href tag dynamic now, but now unable to acccess the HashMap from my MMTUtil which gives mw the value corresponding to my Key(objectName)gUnable to think of any solution I have imported the class in the JSP thats how far I'm able to go

MMTUtil.getDomainComboDocumentationMap().get(objectName);

where objectName is a key and I need to get the value out of it So that it can be used in href

What I have tried: I think this might not work

<%
UMRDocumentationDTO documentationDTO = new UMRDocumentationDTO();
String objectName = documentationDTO.getId().getObjectName();  //getting error here and the debgger goes directly at the end of the page
String tc = MMTUtil.getDomainComboDocumentationMap().get(objectName);
%>

can we try something like this?

for (Map.Entry entry : MMTUtil.getDomainDocumentationMap().entrySet()){
        Object documentationLink =  entry.getValue();
}



<td><a href="<%=documentationLink%>" target="_blank"
id="domainName_<s:property value="#rowstatus.index"/>"><s:property
value="domainName" /></a>

I'm unable to access the Value from my Map in Jsp any error?

public class MMTUtil
{

private static Map<String, String> domainDocumentationMap             = null;

static
{
    domainDocumentationMap = new HashMap<String, String>();
    domainComboDocumentationMap =new HashMap<String, String>();
}

public static Map<String, String> getDomainDocumentationMap() {
    return domainDocumentationMap;
}

public static void setDomainDocumentationMap(String objectName, String documentationLink) {
    MMTUtil.domainDocumentationMap.put(objectName, documentationLink);

//        for(Map.Entry entry:MMTUtil.domainDocumentationMap.entrySet()){
//            System.out.println(entry.getKey() + " " + entry.getValue());
//        }
    }

You need to use expression tag href="<%=tc%>"

If you are getting the correct path in tc.

I hope it will help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM