Reputation: 67
I am trying to return poi excel workbook as a result in struts application while clicked on download button, but it is giving HTTP Status 404 - There is no Action mapped for namespace [/] and action name [send] associated with context path [/Generator].
My web.xml
file is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>ExcelGenerator</display-name>
<welcome-file-list>
<welcome-file>download.jsp</welcome-file>
</welcome-file-list>
<display-name>Struts2FileDownload</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
My struts.xml
file is:
<?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">
<struts>
<constant name="struts.devMode" value="true"></constant>
<package name="Generator" extends="struts-default">
<action name="send" class="org.home.Send" method="execute">
<result name="success" type="stream">
<param name="contentType">application/vnd.ms-excel</param>
<param name="inputName">input</param>
<param name="contentDisposition">application;filename="example.xls"</param>
<param name="bufferSize">4090</param>
</result>
</action>
</package>
</struts>
My project hierarchy is:
Upvotes: 1
Views: 635
Reputation: 1
No action mapped for the url means that Struts can't find the action config that has a mapping printed by the error message.
Indeed the file struts.xm
is in classes
folder under web content root. But it should be on classpath. Move it to Java sources folder or resources, then it will be copied to the right place when you run the application.
Upvotes: 1