2013-04-22 113 views
0

现在我开发简单的JSP portlet(不使用struts)。 我有jsp视图和第二个jsp view_detail.jsp。 在JSP视图我写了这个:Jsp调用另一个jsp

<TD> <a href="<portlet:renderURL ><portlet:param name="view" value="/view_detail.jsp"/></portlet:renderURL>"><%=rs.getInt(1)%></a> 
</TD> 

但doesen't work.Can你帮我请。

回答

0

如果我正确理解你,你应该使用这个API。

请尝试以下步骤:

在您需要包括标签库的view.jsp的的开头:

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %> 
<portlet:defineObjects /> 

然后在要插入的URL,把

<portlet:renderURL><portlet:param name="view" value="/view_detail.jsp" /></portlet:renderURL> 

所以最后<a href>看起来像:

<a href="<portlet:renderURL><portlet:param name="view" value="/view_detail.jsp" /></portlet:renderURL>" target="_blank">Other JSP</A> 

链接无法按照您的方式完成,因为other_jsp.jsp页面显示在另一个页面中,所以您必须链接到门户页面,然后在门户页面中显示您的jsp。

+0

我试过了,但它不起作用。 – user2273574 2013-04-22 01:32:55

+0

对不起,但我不明白,我必须创建一个新的portlet与view_details.jsp? – user2273574 2013-04-22 01:33:44

+0

@ user2273574没有其他JSP,你的情况“view_details.jsp”,应该是在同一Portlet的view.jsp的 – adaam 2013-04-22 01:39:48

0
you should follow the below code and also check in portlet.xml 
<init-param> 
      <name>view-template</name> 
      <value>/jsp/a.jsp</value> 
     </init-param> 
<body> 
     <portlet:renderURL var="other"> 
     <portlet:param name="jspPage" value="/jsp/b.jsp"/> 
     </portlet:renderURL> 
     <a href="<%=other%>">other</a> 
    </body> 
    Example 
    a.jsp 

    <%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%> 
    <%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui"%> 
    <%@ page language="java" contentType="text/html; charset=UTF-8" 
     pageEncoding="UTF-8"%> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <title>Insert title here</title> 
    </head> 
    <body> 
     <portlet:renderURL var="other"> 
     <portlet:param name="jspPage" value="/jsp/b.jsp"/> 
     </portlet:renderURL> 
     <a href="<%=other%>">other</a> 
    </body> 
    </html> 

    b.jsp 

    <%@ page language="java" contentType="text/html; charset=UTF-8" 
     pageEncoding="UTF-8"%> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <title>Insert title here</title> 
    </head> 
    <body> 
    hi karthik 
    </body> 
    </html> 
相关问题