我正在尝试从配置文件存储库中获取名字和姓氏等属性,并使用 droplet 在 jsp 中显示它。下面是我的示例代码: SampleDroplet.java
public class SampleDroplet extends DynamoServlet {
private Repository mProfileRepository;
@Override
public void service(DynamoHttpServletRequest pReq, DynamoHttpServletResponse pRes)
throws ServletException, IOException {
String lFirstName = null;
String lLastName = null;
String lProfileId = pReq.getParameter("profileId");
try {
RepositoryItem lItem = getProfileRepository().getItem(lProfileId, "user");
lFirstName = (String) lItem.getPropertyValue("firstName");
lLastName = (String) lItem.getPropertyValue("lastName");
} catch (RepositoryException e) {
e.printStackTrace();
}
pReq.setParameter("firstName", lFirstName);
pReq.setParameter("lastName", lLastName);
pReq.serviceParameter("output", pReq, pRes);
}
SampleDroplet.properties
$class=com.tap.droplet.SampleDroplet
scope=global
profileRepository=/atg/userProfiling/ProfileAdaptarRepository
SampleDroplet.jsp
<dsp:page>
<dsp:importbean bean="/atg/userprofiling/Profile" var="profile" />
<dsp:importbean bean="/com/tap/droplet/SampleDroplet" />
<dsp:getvalueof var="profileId" bean="Profile.id"/>
<dsp:droplet name="SampleDroplet">
<dsp:param name="profileId" value="${profileId}" />
<dsp:oparam name="output">
Profile's First Name : <dsp:valueof param="firstName"/>
Last Name : <dsp:valueof param="lastName"/>
</dsp:oparam>
</dsp:droplet>
</dsp:page>
我试过在 jsp 中显示 profileId 它正在工作。但是当我将它传递给液滴时,它显示 NullPointerException
java.lang.NullPointerException
at com.tap.droplet.SampleDroplet.service(SampleDroplet.java:26)
at atg.servlet.DynamoServlet.service(DynamoServlet.java:152)
at atg.taglib.dspjsp.DropletTag.invokeServlet(DropletTag.java:420)
at atg.taglib.dspjsp.DropletTag.doAfterBody(DropletTag.java:705)
at jsp_servlet._test._droplet.__sampledroplet._jsp__tag18(__sampledroplet.java:874)
Truncated. see log file for complete stacktrace
如果有人知道是什么问题,请帮助我。
提前致谢