Reputation: 35
I have done the validation for my login form. It's working fine, but after entering correct username
and password
, no action is executed, nor opening JSP page after successful login.
Here is my Login form:
<s:form validate="true" action="login">
<br>
<table class="bg" cellspacing="0">
<tr class="logindiv">
<td >
</td>`enter code here`
<td>
Sign In
</td>
</tr>
<tr>
<td>
<s:textfield label="Username" name="obj2.user" cssStyle="height:25px; width:150px;"></s:textfield>
</td>
</tr>
<tr>
<td>
<s:password label="Password" name="obj2.pass" cssStyle="height:25px;width:150px;"></s:password>
</td>
</tr>
<tr>
<td>
<center>
<s:submit value="Login" cssClass="login"></s:submit>
</center>
</td>
</tr>
</table>
</s:form>
struts.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<action name="login" class="IndianUserActionModule.indianAction" method="Login">
<result name="input">index.jsp</result>
<result name="success">IndianHome.jsp</result>
<result name="fail">index.jsp</result>
</action>
</package>
</struts>
Upvotes: 0
Views: 985
Reputation: 1
In your struts configuration you map the action to a particular namespace of the package config. But in your JSP form you map an action to a default namespace. These are different namespaces and your action config isn't found in the default namespace, so it fails. You should use namespace attribute of your s:form
tag to specify a namespace used to map the action. For example
<s:form validate="true" namespace="/" action="login">
There's an example that would let you better understand the namespaces concept.
Upvotes: 0