struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <lukaszlen...@apache.org>
Subject Re: Why do I get HTTP Status 404 - Not Found after http://localhost:8080/struts2_maven/User/Login.action?
Date Sun, 18 Jun 2017 08:11:47 GMT
You are mixing two different version of Struts - 2.3.x and 2.5.x - you
must stick with one. See my comments below

2017-06-18 4:06 GMT+02:00 ssmtpmailtesting ssmtpmailtesting
<ssmtpmailtesting@gmail.com>:
> http://localhost:8080/struts2_maven/User/Login.action
>
> HTTP Status 404 - Not Found
>
> type Status report
>
> messageNot Found
>
> descriptionThe requested resource is not available.
> GlassFish Server Open Source Edition 4.0
>
> tree .
> .
> ├── pom.xml
> ├── src
> │   ├── main
> │   │   ├── java
> │   │   │   └── com
> │   │   │       └── mkyong
> │   │   │           └── user
> │   │   │               └── action
> │   │   │                   └── WelcomeUserAction.java
> │   │   ├── resources
> │   │   │   ├── struts.xml
> │   │   │   └── struts.xml~
> │   │   └── webapp
> │   │       ├── index.jsp
> │   │       ├── struts2-core-2.5.10.1.jar

This JAR shouldn't be here, remove it

> │   │       ├── User
> │   │       │   └── pages
> │   │       │       ├── login.jsp
> │   │       │       └── welcome_user.jsp

You should move all the JSP files under WEB-INF to increase security
-> http://struts.apache.org/security/#never-expose-jsp-files-directly

> │   │       └── WEB-INF
> │   │           ├── lib
> │   │           ├── struts2-core-2.5.10.1.jar

This JAR shouldn't be here, remove it

> │   │           └── web.xml
> │   └── test
> │       └── java

> 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">

You are using an outdated DTD, please use version 2.5 (when using
Struts 2.5.10.1) or 2.3 (when using Struts 2.3.32)

> <struts>
>
>     <package name="user" namespace="/User" extends="struts-default">
>         <action name="Login">
>             <result>pages/login.jsp</result>

There is no such file, see your file structure, there is "User/pages/login.jsp"

>         </action>
>         <action name="Welcome" class="com.mkyong.user.action.WelcomeUserAction">
>             <result name="SUCCESS">pages/welcome_user.jsp</result>

The same here, also result name is "success" not "SUCCESS"  and you
can omit it if this is the only result type defined - "success" is by
default.

>         </action>
>     </package>
>
> </struts>
>
> web.xml
>
> <!DOCTYPE web-app PUBLIC
>  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>  "http://java.sun.com/dtd/web-app_2_3.dtd" >

Not matching DTD, you are using 2.3 but declared 2.5 version of the
Servlet API in the pom - should be the same.

> <web-app>
>     <display-name>Struts 2 Web Application</display-name>
>
>     <filter>
>         <filter-name>struts2</filter-name>
>         <filter-class>
>
> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

The filter name is wrong, it has changed starting with Struts 2.5
https://struts.apache.org/docs/struts-23-to-25-migration.html#Struts2.3to2.5migration-StrutsPrepareAndExecuteFilter

And finally you should based on out Getting Started Guide which we try
to keep up to date with the latest Struts version
http://struts.apache.org/getting-started/


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message