Struts 2 Hello World

前端 未结 1 691
南方客
南方客 2021-01-22 02:55

I have a problem at this example

I work with eclipse for Java EE and Apache Tomcat 8. My project structure:

The web.xml code:



        
相关标签:
1条回答
  • 2021-01-22 03:31

    First of all the project is created by using Maven configuration, and to access the Struts action you should use url

    Step 6 - Build the WAR File and Run The Application

    Execute mvn clean package to create the war file.

    Copy the war file to your Servlet container. After your Servlet container successfully deploys the war file go to this URL http://localhost:8080/helloworld/index.action where you should see the following:


    (source: apache.org)

    Web application context is where the application was deployed. In the docs url it's /helloworld, on the image it's /Hello_World_Struts2_Ant. Use it as a part of the url. It doesn't matter which app context did you use during deployment but url depends on it. If you want to change the web app context you should read Java - How to change context root of a dynamic web project in Eclipse. After the context you use action name with .action extension to execute action.

    Don't use URLs like localhost:8080/helloworld/index.jsp because you might not get the resource because it's already handled by the web server.

    0 讨论(0)
提交回复
热议问题