2014-06-11 95 views
1

Struts 2的註釋不使用Java 8Struts 2的註釋不使用Java 8

我下面舉個例子,隨着Java 7的工作,但給人的錯誤在Java中8

我猜錯誤與庫和Java 8有關。

有沒有人有這個問題?如果是的話,我們如何解決它?

我用struts 2.3.15.1與Java 8和Apache Tomcat 8.

這個例子是用Java 7的成功合作,支柱2.3.15.1和Apache Tomcat 8.我剛剛測試了。

當我使用Java 8中提供了以下錯誤:

> HTTP Status 404 - There is no Action mapped for namespace [/] and 
> action name [test] associated with context path [/s2demo]. 

的web.xml

<?xml version="1.0" encoding="UTF-8"?> 

<web-app xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
     version="3.0"> 

    <listener> 
     <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class> 
    </listener> 

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

TestAction.java

package action; 

import org.apache.struts2.convention.annotation.Result; 


@Result(name="success", location="/test.jsp") 
public class TestAction { 


    public String execute() { 
     return "success"; 
    } 
} 

test.jsp的

<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <title>JSP Page</title> 
    </head> 
    <body> 
     <h1>Test Successful!</h1> 
    </body> 
</html> 
包括在這個項目中

圖書館是:

asm-3.3.jar 
asm-commons-3.3.jar 
asm-tree-3.3.jar 
commons-beanutils-1.8.0.jar 
commons-digester-2.0.jar 
commons-fileupload-1.3.jar 
commons-io-2.0.1.jar 
commons-lang3-3.1.jar 
commons-logging-1.1.3.jar 
files.txt 
freemarker-2.3.19.jar 
javassist-3.11.0.GA.jar 
log4j-1.2.17.jar 
ognl-3.0.6.jar 
struts2-convention-plugin-2.3.15.1.jar 
struts2-core-2.3.15.1.jar 
struts2-tiles-plugin-2.3.15.1.jar 
tiles-api-2.0.6.jar 
tiles-compat-3.0.1.jar 
tiles-core-2.0.6.jar 
tiles-jsp-2.0.6.jar 
tiles-servlet-3.0.1.jar 
xwork-core-2.3.15.1.jar 
+1

你見過這個:http://stackoverflow.com/q/23588099/1700321? –

回答