0

I am trying to change default url in my application using below code,

struts.xml :

<!DOCTYPE struts PUBLIC
   "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
   "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
  <constant name="struts.action.extension" value="htm"/>

  <package name="default" namespace="/" extends="struts-default"  >

   <action name="LoginClass" class="com.struts2.LoginCheckingClass" method="execute">
   <result name="input">/Home.jsp</result>
   <result name="success" type="dispatcher">/LoginSuccessPage.jsp</result>
   <result name="error">/Home.jsp</result> 
   </action> 
  </package>  

</struts>

Home.jsp :

<s:actionerror/><s:fielderror />
<br>
<s:form action="LoginClass" method="post" validate="true">

<s:textfield name="Uname" label="User Name" />

<s:textfield name="Pwd" label="Password" />

<s:submit validate="true"  type="image" src="button-login2.png"/>

</s:form>

But when submit in Home.jsp the page always goes to 404 error page.I saw all tutorials and doing that same way but still i am getting same error.

If i remove the <constant name="struts.action.extension" value="htm"/> from struts.xml then page redirecting to represented page correctly.

someone help me out where am i doing wrong?

MMMMS
  • 2,179
  • 9
  • 43
  • 83
  • Which url do you see in the browser upon receiving 404? Any error in console? – Aleksandr M Jul 06 '15 at 13:12
  • @AleksandrM i can see this http://localhost:8080/Struts2Application/LoginClass url while getting 404. and no error in console. – MMMMS Jul 07 '15 at 04:19
  • 1
    This is strange... You can change `struts.action.extension` to `value="htm,,"`. – Aleksandr M Jul 07 '15 at 08:50
  • @AleksandrM omg... its working after change to value="htm,,". why?how? – MMMMS Jul 07 '15 at 11:57
  • It is working because with `htm,,` the empty action extension is also allowed. The question is why it doesn't add `htm` to your action. Maybe you are doing some filtering or submitting this form with ajax? – Aleksandr M Jul 07 '15 at 11:59
  • See http://stackoverflow.com/q/12607075/1700321. – Aleksandr M Jul 07 '15 at 12:00
  • No i am not try with ajax i just want to display url Struts2Application/LoginClass.htm or Struts2Application/LoginClass.jsp instead of Struts2Application/LoginClass.action – MMMMS Jul 07 '15 at 12:03

0 Answers0