2009-11-12 63 views
0

我是struts标签库的新手。我想要生成一个锚点来在同一个文档中定义一个超链接目标。我的代码是这样的:<html:link>标签

<html:link anchor="abc" > 
      This is to test anchors 
</html:link> 

...Some other tags here 

<html:link linkName = "abc" > 
      Anchor 
</html:link> 

我得到的错误是Cannot create rewrite URL: java.net.MalformedURLException: You must specify exactly one of "forward", "href", or "page"

任何人能告诉我怎么解决这个问题?
感谢

回答

1

据我所知支柱和apache

You must specify exactly one of the action attribute, the forward attribute, the href attribute, the linkName attribute, or the page attribute.

所以在你的第一个标签,我猜你会需要添加一个href标记和锚被添加到这一点。然后用链接名称的标签应该工作

<html:link href="someurl" anchor="abc" > 
      This is to test anchors 
</html:link> 
+0

但超链接的目标是在同一doccument。所以我们仍然需要指定href?在HTML等效 href =“#abc”我们不指定url如果它在同一个document.how在struts中执行它? – daniel

+0

您需要设置href,因为它是先决条件。 (或至少一个上面指定的属性)。所以如果它在同一页面上,我想你会设置href =“#”和anchor =“abc”。 – Kamal

1

这为我工作。 以下是我遇到错误的场景。

<appl:resource defaultValue="Appl Error" op="GET" category="shunmugaActionMapping" name="specification" property="shunmugaType" id="shunmugaStartMapping" type="string" > 
    <td class="<xd:valueOf name="rowStyle"/>"> 
     <div class="listRowLink"><html:link page="<%=shunmugaStartMapping%>" paramName="specification" paramProperty="routerId" paramId="detailRouterId">&gt; Details</html:link> 
     </div> 
    </td> 

这被扔了以下错误:

servlet E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: 
Uncaught exception created in one of the service methods of the servlet 
/jsp/List.jsp in application Sundaram. Exception created : 
com.ibm.websphere.servlet.error.ServletErrorReport: 
javax.servlet.jsp.JspException: Cannot create rewrite URL: 
java.net.MalformedURLException: You must specify exactly one of 
"forward", "href", "page" or "action" 
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:695) 

我所做的一切是我加了封底:

</appl:resource> 

的问题得到了解决,我现在很好。

感谢, Shunmuga

+0

+1用于提供错误消息和示例代码 – scraimer