小编tta*_*mas的帖子

Liferay portlet不接收表单数据

我在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!它会导致问题吗?

jsp portlet liferay

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

jsp ×1

liferay ×1

portlet ×1