简体   繁体   中英

Spring mvc portlet: how to get data from jsp?

I have a problem, how can I send my data from html form in jsp (portlet) to controller? Here some code

Portlet JSP

<form id="smsSender" method="post" action="${sendSmsUrl}">    
<input type="text" name="phoneSuffix" maxlength="7"/>
<textarea id="message" maxlength="70" name="message"></textarea>
<br>
<input type="submit" value="Send">
</form>
<portlet:actionURL name="sendSms" var="sendSmsUrl">
</portlet:actionURL>

Controller

@Controller
@RequestMapping("VIEW")
public class SmsController extends MVCPortlet {

@ActionMapping
public void sendSms(ActionRequest request, ActionResponse response) {
        String message = ParamUtil.get(request, "message", "");        
    }
}

Please, help me understand how to do it correctly? Thanks!

The problem seems to be because of qualified parameters for portlet:

Possible solution are:

i. Use aui html tags.

<aui:form id="smsSender" method="post" action="${sendSmsUrl}">    
    <aui:input type="text" name="phoneSuffix" maxlength="7" />
    <aui:input type="textarea" id="message" maxlength="70" name="message" />
    <br />
    <aui:button type="submit" value="Send" />
</form>

OR

ii. Add <portlet:namespace /> to the field(s) name attribute:

<textarea id="<portlet:namespace />message" 
    maxlength="70" name="<portlet:namespace />message"></textarea>

OR

iii. Add <requires-namespaced-parameters>false</requires-namespaced-parameters> in liferay-portlet.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM