tta*_*mas 2 jsp portlet liferay
我在Liferay中制作了一个显示表单的portlet.我想在提交后处理表单数据,但数据在某处"消失".
这是我在jsp中的表单代码:
<portlet:actionURL windowState="normal" var="filterURL">
</portlet:actionURL>
<form action="<portlet:actionURL />" method="post">
Industry: <input type="text" name="<portlet:namespace />industry" value="<%= industryFilter %>"/>
<input type="submit" value="Filter" />
</form>
Run Code Online (Sandbox Code Playgroud)
数据应该传递给我的portlet类,但不会.这是我的班级代码:
public void processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {
String industryFilter = actionRequest.getParameter("industry");
if(industryFilter == null) {
industryFilter = "no-param";
}
actionResponse.setRenderParameter("industry", industryFilter);
super.processAction(actionRequest, actionResponse);
}
Run Code Online (Sandbox Code Playgroud)
该类旨在将数据传递回jsp.该setRenderParameter()方法工作正常,因为在jsp中我可以使用读取值request.getParameter("industry");但是,它总是返回"no-param",这意味着actionRequest.getParameter()返回null.
所以,似乎我的processAction方法被正确调用,但它没有收到表单数据.错误在哪里,我错了什么?
更新:
我将portlet下载到我的本地计算机,部署到本地演示Liferay安装,它工作正常!所以代码应该没问题,它必须是一些服务器设置/问题.我发现在Chrome开发人员工具的网络选项卡中,本地服务器只有一个状态为200的POST调用,而在远程服务器上有一个POST,其中302暂时移动,GET 200具有相同的URL!它会导致问题吗?
您应该为您的name值添加名称空间前缀,如下所示:
<input type="text" name="<portlet:namespace />inputTextName" />
Run Code Online (Sandbox Code Playgroud)
或者你可以requires-namespaced-parameters在你的设置中将设置设置为false liferay-portlet.xml.
自Liferay 6.2以来,这是一个变化:https://github.com/liferay/liferay-aui-upgrade-tool/issues/30
| 归档时间: |
|
| 查看次数: |
12248 次 |
| 最近记录: |