This problem plagued me one afternoon. I checked some struts getting started tutorials on the Internet at night to find out the key issue, because my struts. xml configuration is incorrect. My original struts. xmlCodeAs follows:
XML Version = "1.0" Encoding = UTF-8" ?> Doctype Struts Public "-// Apache Software Foundation // DTD struts configuration 2.1 // en" Http://struts.apache.org/dtds/struts-2.1.dtd" > Struts >Package Name = "Struts2" Extends = "Struts-Default" > Action Name = "Query" Class = "Chapter7.action. queryaction" >ResultName="Result">/Result. jspResult>ResultName="Error">/Error. jspResult>Action>Package>Struts>
You need to change the above Code to the following code:
XML Version = "1.0" Encoding = UTF-8" ?> Doctype Struts Public "-// Apache Software Foundation // DTD struts configuration 2.1 // en" Http://struts.apache.org/dtds/struts-2.1.dtd" > Struts > Package Name = "Struts2" Namespace = "/" Extends = "Struts-Default" > Action Name = "Query" Class = "Chapter7.action. queryaction" >ResultName="Result">/Result. jspResult>ResultName="Error">/Error. jspResult>Action>Package>Struts>
That is Namespace = "/" extends = "struts-Default">.
the action interface is accessed through http: // localhost: 8080/strutstest1/query. Action. If namespace is changed to namespace = "/Hello", the access address on the Action interface should be changed to http: // localhost: 8080/strutstest1/Hello/query. Action.