如何使用带有java类值的JSP获取动态href标记

时间:2022-11-27 17:55:46

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

我现在能够获得href标签动态,但是现在无法从我的MMTUtil中获取HashMap,这给了mw与我的Key(objectName)相对应的值gUnable可以想到我在JSP中导入类的任何解决方案如何我能走了

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

其中objectName是一个键,我需要从中获取值,以便它可以在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?

我无法从Jsp中的Map访问Value中的任何错误?

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());
//        }
    }

1 个解决方案

#1


1  

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

你需要使用表达式标签href =“<%= tc%>”

If you are getting the correct path in tc.

如果你在tc中获得正确的路径。

I hope it will help you.

我希望它会对你有所帮助。

#1


1  

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

你需要使用表达式标签href =“<%= tc%>”

If you are getting the correct path in tc.

如果你在tc中获得正确的路径。

I hope it will help you.

我希望它会对你有所帮助。