Re: Struts examples Hello World

Lukasz Lenart <[email protected]>
Newsgroups gmane.comp.jakarta.struts.user
Message-ID <CAMopvkMQkY7gZGCgm-TGp5b71gHMN7KQmq86h5An2ZEKRoYXDg@mail.gmail.com>
niedz., 14 kwi 2024 o 20:56 Tim Mousaw <[email protected]> napisał(a):
>
> I started to go through the Getting Started examples at
> https://struts.apache.org/getting-started/index.html. I downloaded all the
> examples from https://github.com/apache/struts-examples. I would expect
> that I should be able to run `mvn jetty:run` from any of the examples,
> follow the appropriate link, and it should work as in the corresponding
> tutorial. However, this breaks down very quickly as when I try to run that
> for the `helloworld` example, I get the following error in my web browser
> when going to the link http://localhost:8080/helloworld/index.action:
> HTTP ERROR 404 Not Found
> URI: /helloworld/index.action
> STATUS: 404
> MESSAGE: Not Found
> SERVLET: default
> ------------------------------
> Powered by Jetty:// 9.4.46.v20220331 <https://eclipse.org/jetty>
>
> With debug logging enabled, navigating to
> localhost:8080/helloworld/index.action spits the following two lines of
> output to the console:
> 2024-04-14 14:44:44,340 DEBUG [qtp273531298-62] config.ConfigurationManager
> (ConfigurationManager.java:180) - Checking ConfigurationProviders for
> reload.
> 2024-04-14 14:44:44,343 DEBUG [qtp273531298-62]
> impl.InstantiatingNullHandler (InstantiatingNullHandler.java:98) - Entering
> nullPropertyValue
> [target=[com.opensymphony.xwork2.DefaultTextProvider@6dbebaa7],
> property=struts]
>
> If I remove the line "<constant name="struts.action.extension" value=","/>"
> from struts.xml, then the example seems to work. It gets the same two lines
> of output to the console followed by:

You are right, by removing this constant you make Struts to fallback
to default configuration [1] which supports both .action and no suffix
in the url

[1] https://github.com/apache/struts/blob/master/core/src/main/resources/org/apache/struts2/default.properties#L87

> 2024-04-14 14:51:46,765 DEBUG [qtp273531298-50] xwork2.DefaultActionProxy
> (DefaultActionProxy.java:85) - Creating an DefaultActionProxy for namespace
> [/] and action name [index]
>
> As well as a bunch of other logging after that before the page renders.
> From searching for this configuration, I think the intention of this line
> is to remove the `.action` suffix from the action (e.g. the link in the web
> browser displays localhost:8080/helloworld/index rather than
> http://localhost:8080/helloworld/index.action). So, I'm curious what I have
> configured wrong that doesn't allow this to work. I'm using Java 21
> (Corretto). Let me know if there are other dependencies that you need to
> know the version of.

As you notice what was documented on the page doesn't match the
example Hello World application. So either you can prepare a PR fixing
the documentation or the example app.


Cheers
Lukasz
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.