Java Struts和jasper配置问题

Java Struts和jasper配置问题,java,struts2,jasper-reports,action-mapping,Java,Struts2,Jasper Reports,Action Mapping,运行URL()时,错误消息中的操作名称为空。即使是我也无法通过参考其他stackoverflow Q找到问题。如果你们中有人能帮我解决这个问题,我真的很感激。下面提到了我的项目源代码以及我的控制台错误消息。谢谢 Error Message HTTP Status 404 - There is no Action mapped for namespace [/] and action name [] associated with context path [/Jasper]. Dec

运行URL()时,错误消息中的操作名称为空。即使是我也无法通过参考其他stackoverflow Q找到问题。如果你们中有人能帮我解决这个问题,我真的很感激。下面提到了我的项目源代码以及我的控制台错误消息。谢谢

Error Message 
HTTP Status 404 - There is no Action mapped for namespace [/] and action name [] associated with context path [/Jasper].

    Dec 27, 2015 3:30:49 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
SEVERE: Exception occurred during processing request: There is no Action mapped for namespace [/] and action name [] associated with context path [/Jasper].
There is no Action mapped for namespace [/] and action name [] associated with context path [/Jasper]. - [unknown location]
    at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
    at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
    at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
    at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:534)
    at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
strutsjasper.xml

<struts>

<package name="default" namespace="/" extends="jasperreports-default">
    <action name="myJasperTest" class="com.acme.test.action.JasperAction">
        <result name="success" type="jasper">
            <param name="location">/jasper/our_compiled_template.jasper</param>
            <param name="dataSource">myList</param>
            <param name="format">PDF</param>
        </result>
    </action>

</package>
</struts>

/jasper/our_编译的_template.jasper
迈利斯特
PDF
Web.xml

<display-name>Struts2Jasper</display-name>`<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>


</welcome-file-list>`


<filter>
    <filter-name>struts2</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>

<filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping> 
Struts2Jasper`
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
`
支柱2
org.apache.struts2.dispatcher.ng.filter.strutspreadexecutefilter
支柱2
/*
JasperAction类

public class JasperAction extends ActionSupport {

/** List to use as our JasperReports dataSource. */
private List<Person> myList;

public String execute() throws Exception {

    // Create some imaginary persons.
    Person p1 = new Person(new Long(1), "Patrick", "Lightbuddie");
    Person p2 = new Person(new Long(2), "Jason", "Carrora");
    Person p3 = new Person(new Long(3), "Alexandru", "Papesco");
    Person p4 = new Person(new Long(4), "Jay", "Boss");

    // Store people in our dataSource list (normally they would come from a database).
    myList = new ArrayList<Person>();
    myList.add(p1);
    myList.add(p2);
    myList.add(p3);
    myList.add(p4);

    // Normally we would provide a pre-compiled .jrxml file
    // or check to make sure we don't compile on every request.
    try {
        JasperCompileManager.compileReportToFile(
                "S2_WEBAPP/jasper/our_jasper_template.jrxml",
                "S2_WEBAPP/jasper/our_compiled_template.jasper");
    } catch (Exception e) {
        e.printStackTrace();
        return ERROR;
    }

    return SUCCESS;
}

public List<Person> getMyList() {
    return myList;
}
}

Person class
public class Person {

private Long id;

private String name;

private String lastName;

public Person() {
}

public Person(String name, String lastName) {
    this.name = name;
    this.lastName = lastName;
}

public Person(Long id, String name, String lastName) {
    this.id = id;
    this.name = name;
    this.lastName = lastName;
}

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public String getLastName() {
    return lastName;
}

public void setLastName(String lastName) {
    this.lastName = lastName;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}}
公共类JasperAction扩展了ActionSupport{
/**要用作JasperReports数据源的列表*/
私人名单;
公共字符串execute()引发异常{
//创造一些假想的人。
人员p1=新人员(新长(1),“Patrick”,“Lightbuddie”);
人员p2=新人员(新长(2),“Jason”,“Carrora”);
人员p3=新人员(新长(3),“Alexandru”,“Papesco”);
人员p4=新人员(新长(4),“Jay”,“Boss”);
//将人员存储在我们的数据源列表中(通常他们来自数据库)。
myList=新的ArrayList();
myList.add(p1);
myList.add(p2);
myList.add(p3);
myList.add(第4页);
//通常我们会提供一个预编译的.jrxml文件
//或者检查以确保我们不会对每个请求进行编译。
试一试{
JasperCompileManager.compileReportToFile(
“S2_WEBAPP/jasper/our_jasper_template.jrxml”,
“S2_WEBAPP/jasper/our_compiled_template.jasper”);
}捕获(例外e){
e、 printStackTrace();
返回误差;
}
回归成功;
}
公共列表getMyList(){
返回myList;
}
}
人类
公共阶层人士{
私人长id;
私有字符串名称;
私有字符串lastName;
公众人士(){
}
公众人物(字符串名称、字符串姓氏){
this.name=名称;
this.lastName=lastName;
}
公众人物(长id、字符串名称、字符串姓氏){
this.id=id;
this.name=名称;
this.lastName=lastName;
}
公共长getId(){
返回id;
}
公共无效集合id(长id){
this.id=id;
}
公共字符串getLastName(){
返回姓氏;
}
public void setLastName(字符串lastName){
this.lastName=lastName;
}
公共字符串getName(){
返回名称;
}
公共void集合名(字符串名){
this.name=名称;
}}

我的Jrxml位于WebContent/S2_WEBAPP/jasper/

你从哪里想到可以随意命名struts.xml文件而不需要任何配置?@Roman C你能解释一下@Aleksandr我需要在哪里配置吗?只要将你的
strutsjasper.xml
重命名为
struts.xml