struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Pratt <thechrispr...@gmail.com>
Subject Re: Url rewriting of .action to .jsp
Date Sun, 22 Sep 2013 08:41:24 GMT
That's because you are submitting that action.  If that's not what you
intended, I don't understand what you are trying to achieve.  The setting I
suggested allows you to rename the .action url extension to .jsp (or .html).
  (*Chris*)


On Sun, Sep 22, 2013 at 1:30 AM, Serdyn du Toit <dutoitns@gmail.com> wrote:

> Hi Chris,
>
> Not exactly what I'm looking for,
>
> If I now type:
> http://localhost:8080/rf-adminweb/admin/login/login.jsp
>
> Then it thinks I'm submitting the form - so my form validation errors get
> displayed.
> (ie it thinks I'm submitting the form:
> http://localhost:8080/rf-adminweb/admin/login/login.<http://localhost:8080/rf-adminweb/admin/login/login.jsp>
> action)
>
> Is there something else I need to add to the config as well?
>
> Sorry, I'm a bit new to Struts 2 so my configuration isn't yet 100% the
> way I would like it - so there might be something in addition to that
> property I might have missed.
>
> Don't think its going to help, but my struts.xml:
> <struts>
>     <!-- No Actions are defined here. -->
>     <include file="struts-actions.xml" />
>     <constant name="struts.devMode" value="false" />
>     <constant name="struts.i18n.reload" value="false" />
>     <constant name="struts.configuration.xml.reload" value="false" />
>      <!-- Configure Struts 2 theme. -->
>     <!--
>
> http://stackoverflow.com/questions/4561179/how-to-disable-struts-2-table-generation-for-form
>          http://struts.apache.org/2.3.4.1/docs/cssxhtml-theme.html
>          http://struts.apache.org/2.3.4.1/docs/extending-themes.html
>
> http://www.mkyong.com/struts2/working-with-struts-2-theme-template/
>          http://struts.apache.org/2.3.4.1/docs/template-loading.html
>
>          As of Struts 2.0.10, setting the property
> struts.freemarker.templatesCache
>          to true will enable the Struts internal caching of Freemarker
> templates.
>          This property is set to false by default.
>     -->
>     <constant name="struts.freemarker.templatesCache" value="true" />
>     <constant name="struts.ui.templateDir" value="template" />
>     <constant name="struts.ui.theme" value="custom" />
>
> <!-- http://struts.apache.org/release/2.3.x/docs/struts-defaultxml.html-->
>  <package name="default" abstract="true" extends="struts-default">
> <interceptors>
>     <interceptor name="checkAuthenticationInterceptor"
> class="com.d6.adminweb.login.session.AdminAuthenticationInterceptor" />
> <interceptor-stack name="any">
>     <interceptor-ref name="validationWorkflowStack" />
>     </interceptor-stack>
>  <interceptor-stack name="authenticate">
>     <interceptor-ref name="checkAuthenticationInterceptor" />
>     <interceptor-ref name="validationWorkflowStack" />
>             </interceptor-stack>
>     </interceptors>
>     <default-interceptor-ref name="authenticate" />
>     <global-results>
>     <result name="sessionExpired">/admin/login/sessionExpired.jsp</result>
>  </global-results>
> </package>
> </struts>
>
> Kind regards,
> Serdyn du Toit
>
>
>
> On Sun, Sep 22, 2013 at 9:36 AM, Chris Pratt <thechrispratt@gmail.com>wrote:
>
>> Put the following in your struts.xml configuration file:
>>
>>  <constant name="struts.action.extension" value="jsp"/>
>>
>> I actually prefer:
>>
>>   <constant name="struts.action.extension" value="html"/>
>>
>> since it hides the underlying technology just a bit better and makes a
>> tiny
>> bit harder for someone to guess how to hack it.  It's not high security,
>> but every little bit helps.
>>   (*Chris*)
>>
>>
>>
>> On Sat, Sep 21, 2013 at 10:44 PM, Serdyn du Toit <dutoitns@gmail.com>
>> wrote:
>>
>> > Hi,
>> >
>> > I have the following Struts action defined in Xml:
>> >     <package name="login" namespace="/admin/login" extends="default">
>> >         <default-interceptor-ref name="any" />
>> >
>> >         <action name="login"
>> > class="com.d6.adminweb.login.AdminUserLoginAction">
>> >             <result name="input">/admin/login/login.jsp</result>
>> >             <result name="success"
>> > type="redirect">/admin/dashboard/frames.jsp</result>
>> >         </action>
>> >     </package>
>> >
>> > When I submit the page and validation fails my browser has the following
>> > Url:
>> > http://localhost:8080/webapp/admin/login/login.action<
>> > http://localhost:8080/rf-adminweb/admin/login/login.action>
>> >
>> > How can I make it display
>> > http://localhost:8080/webapp/admin/login/login.j<
>> > http://localhost:8080/rf-adminweb/admin/login/login.action>
>> > sp
>> >
>> > If I never see .action in the browser I'd be happy :)
>> >
>> > I want it to be login.jsp so that someone can bookmark the page even
>> after
>> > a failed form submission.  Sure, one can bookmark login.action - but
>> then
>> > when you load the page you're going to see a lot of errors due to empty
>> > input fields (the Action's validation)
>> >
>> > Using a "redirect" worked for the second result type:
>> >             <result name="success"
>> > type="redirect">/admin/dashboard/frames.jsp</result>
>> >
>> > But in this case if I do that then my errors are no longer displayed on
>> the
>> > page (guess it gets lost when I redirect)
>> >
>> > Any suggestions appreciated :)
>> >
>>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message