Struts Hello world example : There is no Action mapped for namespace [/] and action name error

自古美人都是妖i 提交于 2019-11-29 03:51:35

The struts.xml configuration file needs to be on the classpath (as opposed to in WEB-INF).

The linked tutorial assumes a Maven build and states the struts.xml file should go in src/main/resources, which will be included in the classpath in Maven builds. Since you're ignoring that part, you'll likely want to put it in the root of your source directory.

Riadh

You have to create a classes/ folder under WEB-INF/ and put in your struts.xml file!

Right click the project. Go to properties deployment build path and add all .jar files to /WEB-INF/lib.
Then you shouldn't get this error.

struts.xml should be located under directory: src/struts.xml..

And WEB-INF/web.xml you we need to configure the struts based on filter..

seb

I got the same error and got solution looking at tomcat log when restarting : doctype were missing in struts.xml

so I added

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

now it works !

I solved the issue by adding default-action-ref tag, for example,

<default-action-ref name="home" />

after package tag

in struts.xml

<package name="user" namespace="/" extends="struts-default">

<default-action-ref name="upload" />
joshi0788

I had the same issue and I was facing it because of not mentioning the namespace correctly in struts.xml.

I added the following snippet in the web.xml :

<welcome-file>login.jsp</welcome-file>

and also making the namespace as "/" default... Hope it answers your query..

Andrew Tar

In my case I had to rename Struts.xml ---> struts.xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!