portlet - 符合 JSR 286 的命名空间参数

标签 portlet liferay-6 websphere-portal jsr286

在 portlet 中,读取操作方法中的命名空间参数的最佳方法是什么。 我的表单包含

<input id="<portlet:namespace/>param1"  name="<portlet:namespace/>param1" value='hello'/>

选项1:

request.getParameter(response.getNamespace() + "param1");

选项2:

request.getParameter("param1");

选项1在liferay中不起作用,但似乎在websphere中起作用。 option2 在 liferay 6.2 中工作正常。 option1 似乎在 6.1 之前有效。

谁能告诉我什么是 jsr 286 兼容方式?

最佳答案

正如我在对该问题的回答的评论中提到的,问题出在 Liferay 6.2 上,因为 IBM WebSphere 和以前版本的 Liferay 正在按预期工作。

为了解决这个问题,我添加了元素 <requires-namespaced-parameters>false</requires-namespaced-parameters>liferay-portlet.xml /WEB-INF的portlet 的目录。通过这样做,HTML 表单的参数就不会被“命名空间”。

/WEB-INF/liferay-portlet.xml 的示例:

<?xml version="1.0" encoding="UTF-8"?>
<liferay-portlet-app>
  <portlet>
    <portlet-name>Portlet name</portlet-name>
    <requires-namespaced-parameters>false</requires-namespaced-parameters>
    <instanceable>true</instanceable>
    <ajaxable>false</ajaxable>
  </portlet>
</liferay-portlet-app>

如果将此元素添加到 liferay-portlet.xml ,该 portlet 在 Liferay 的早期版本中仍然可以正常工作(我使用版本 5.5 和 6.1 进行了测试)。它也适用于其他包含的 portlet,因为它们会忽略此文件。

我声称 Liferay 行为不正确,因为 JSR-286 规范有以下规定(规范第 76 页顶部):

If portlets namespace or encode URL parameters or form parameters they are also responsible for removing the namespace. The portlet container will not remove any namespacing the portlet has done on these parameters."

关于portlet - 符合 JSR 286 的命名空间参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21550030/

相关文章:

java - Node.js 和 WebSphere Portal 之间的单点登录

portlet - Spring MVC Portlet 和 Liferay : No matching handler method found for portlet request actionUrl

liferay - 如何设置aui中选定的值:select box

websphere-portal - 将网站迁移到 IBM Web Content Manager 8

java - 将 Web 应用程序引入 IBM Websphere Portal 6.0

liferay - 如何在liferay上设置自定义410页面

将 WAR 文件部署到 Liferay 时未创建 SQL 表

java - 将 Maven 用于 Ibm Web Experience Factory 又名 IBM WebSphere Portlet Factory 项目?

java - 如何实现 JSR 规范

jboss - 在 Velocity/JS/CSS 中自定义 Liferay 6 Dockbar