Search code examples
javajspstrutsstruts-1

How to pass ID to action.java in struts?


I have this code in jsp file :

<%
    int j = 1;
    while (variableTypesIterator.hasNext()) {
        VariableType c = new VariableType();
        c = variableTypesIterator.next();
        if (variableTypeId != null && c.getVariableTypeId().equals(variableTypeId)) {
%>
<br/>
<li><label><%=c.getVariableTypeId()%>
</label> <html:link action="/policyBasicInfo.do?method=selectedVariableType"
                    style="text-decoration: none;"><%=c.getVariableTypeName()%>
</html:link></li>
<%
} else {
%>
<br/>
<li><html:link action="/policyBasicInfo.do?method=selectedVariableType"
               style="text-decoration: none;"><%=c.getVariableTypeName()%>
</html:link></li>
<input type="VtId" id="VtId" name="VtId" value="<%=c.getVariableTypeId()%>"/>
<%
        }
        j++;
    }
%>
<%
    }
%>

How to pass ID ( Input text Value ) to action File in struts? When the user Click link?


Solution

  • The easier approach will be

    <a href="/policyBasicInfo.do?method=selectedVariableType&variableTypeId=<%=c.getVariableTypeId()%>"><%=c.getVariableTypeName()%></a>