java - liferay portlet spring mvc form is empty -


i have problem. form submit empty.

public class customer implements serializable{      private static final long serialversionuid = 1l;     private string firstname;     private string middlename;     private string lastname;     private int age;     private string address;      public string getfirstname() {         return firstname;     }      public void setfirstname(string firstname) {         this.firstname = firstname;     }      public string getmiddlename() {         return middlename;     }      public void setmiddlename(string middlename) {         this.middlename = middlename;     }      public string getlastname() {         return lastname;     }      public void setlastname(string lastname) {         this.lastname = lastname;     }      public int getage() {         return age;     }      public void setage(int age) {         this.age = age;     }      public string getaddress() {         return address;     }      public void setaddress(string address) {         this.address = address;     } } 

portletviewcontroller

@controller @requestmapping("view") public class portletviewcontroller {       @rendermapping     public string viewhomepage(renderrequest request, renderresponse response) {          return "test/view";     }      @rendermapping(params = "action=showform")     public string viewbyparameter(map<string, object> map) {          customer customer = new customer();         map.put("customer", customer);         return "test/form";     }      @rendermapping(params = "action=success")     public string viewsuccess() {         return "test/success";     }      @actionmapping(value = "handlecustomer")     public void getcustomerdata(@modelattribute("customer") customer customer,             actionrequest actionrequest, actionresponse actionresponse,             model model) {          actionresponse.setrenderparameter("action", "success");          model.addattribute("successmodel", customer);     } } 

form.jsp

<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%> <%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %> <portlet:defineobjects /> <portlet:actionurl var="submitformurl" name="handlecustomer"/> <form:form name="customer" method="post" modelattribute="customer" action="   <%=submitformurl.tostring() %>"> <br/> <table style="margin-left:80px">     <tbody>         <tr>             <td><form:label path="firstname">first name</form:label></td>             <td><form:input path="firstname"></form:input></td>         </tr>         <tr>             <td><form:label path="middlename">middle name</form:label></td>             <td><form:input path="middlename"></form:input></td>         </tr>         <tr>             <td><form:label path="lastname">last name</form:label></td>             <td><form:input path="lastname"></form:input></td>         </tr>         <tr>             <td><form:label path="age">age</form:label></td>             <td><form:input path="age"></form:input></td>         </tr>         <tr>             <td><form:label path="address">address</form:label></td>             <td><form:input path="address"></form:input></td>         </tr>          <tr>             <td colspan="2"><input type="submit" value="submit form">             </td>         </tr>     </tbody> </table> </form:form> 

success.jsp

<div> <h3>form submitted successfully</h3> </div>  <div> first name: ${successmodel.firstname} </div>  <div> middle name: ${successmodel.middlename} </div>  <div> last name: ${successmodel.lastname} </div>  <div> age: ${successmodel.age} </div>  <div> address: ${successmodel.address} </div> 

view.jsp

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>  <portlet:defineobjects />  <portlet:renderurl var="renderurl">     <portlet:param name="action" value="showform"/> </portlet:renderurl>  <h3> spring form submission demo</h3>  <br/><br/>  <a href="<%=renderurl.tostring()%>">go form page</a> 

web.xml

<?xml version="1.0"?>  <web-app     version="2.5"     xmlns="http://java.sun.com/xml/ns/javaee"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" >     <context-param>         <param-name>contextconfiglocation</param-name>         <param-value>/web-inf/spring-context/portlet-application-context.xml</param-value>     </context-param>     <servlet>         <servlet-name>viewrendererservlet</servlet-name>         <servlet-class>org.springframework.web.servlet.viewrendererservlet</servlet-class>         <load-on-startup>1</load-on-startup>     </servlet>     <servlet-mapping>         <servlet-name>viewrendererservlet</servlet-name>         <url-pattern>/web-inf/servlet/view</url-pattern>     </servlet-mapping>     <listener>         <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>     </listener> </web-app> 

portlet.xml

<?xml version="1.0"?>  <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">     <portlet>         <portlet-name>test</portlet-name>         <display-name>test</display-name>         <portlet-class>org.springframework.web.portlet.dispatcherportlet</portlet-class>         <init-param>             <name>contextconfiglocation</name>             <value>/web-inf/spring-context/portlet/test-portlet.xml</value>         </init-param>         <expiration-cache>0</expiration-cache>         <supports>             <mime-type>text/html</mime-type>         </supports>         <portlet-info>             <title>test</title>             <short-title>test</short-title>             <keywords>test</keywords>         </portlet-info>         <security-role-ref>             <role-name>administrator</role-name>         </security-role-ref>         <security-role-ref>             <role-name>guest</role-name>         </security-role-ref>         <security-role-ref>             <role-name>power-user</role-name>         </security-role-ref>         <security-role-ref>             <role-name>user</role-name>         </security-role-ref>     </portlet> </portlet-app> 

portlet-application-context.xml

<?xml version="1.0"?>  <beans         xmlns="http://www.springframework.org/schema/beans"         xmlns:context="http://www.springframework.org/schema/context"         xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"         xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd" >     <context:annotation-config/>       <bean id="viewresolver" class="org.springframework.web.servlet.view.internalresourceviewresolver">         <property name="contenttype" value="text/html;charset=utf-8"/>         <property name="prefix" value="/web-inf/jsp/"/>         <property name="suffix" value=".jsp"/>         <property name="viewclass" value="org.springframework.web.servlet.view.jstlview"/>     </bean> </beans> 

test-portlet.xml

<?xml version="1.0"?>  <beans     xmlns="http://www.springframework.org/schema/beans"     xmlns:context="http://www.springframework.org/schema/context"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd" >     <context:component-scan base-package="test.**" /> </beans> 

can me?

why customer submit empty?

i found mistake. in liferay-portlet.xml following must added.

<requires-namespaced-parameters>false</requires-namespaced-parameters> 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -