java代码:package com.test;import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;import com.opensymphony.xwork2.ActionSupport;@Namespace("/com")
@Action(value = "testStru2",
results = { @Result(
name = "success",
location = "/hello.jsp") })public class TestStru2Action extends ActionSupport{
public String execute(){
System.out.println("=========");
return SUCCESS;
}
public String test1(){
System.out.println("=========1");
return SUCCESS;
}
}
struts.xml:<?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.enable.DynamicMethodInvocation" value="false"
/> <constant name="struts.devMode" value="false" /> <include
file="example.xml"/> <package name="default" namespace="/"
extends="struts-default"> <default-action-ref name="index" /> <action
name="index"> <result type="redirectAction"> <param
name="actionName">HelloWorld</param> <param
name="namespace">/example</param> </result> </action> </package>
-->
<!-- 开发模式 value设置为true -->
<constant name="struts.devMode" value="true" />
<constant name="struts.configuration.xml.reload" value="true"/>
<constant name="actionPackages" value="com.test" />
<package name="hello" extends="struts-default">
</package>
</struts>
web.xml:<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
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_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>actionpackage</param-name>
<param-value>com.test</param-value>
</init-param>
</filter> <filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>hello.jsp</welcome-file>
</welcome-file-list>
</web-app>
lib:
commons-fileupload-1.2.1.jar,
commons-io-1.3.2.jar,
freeer-2.3.16.jar。
javassist-3.7.ga.jar,
ognl-3.0.jar,
struts2-core-2.2.1.1.jar,
xwork-core-2.2.1.1.jar,
struts2-convention-plugin-2.2.1.1.jar,
struts2-config-browser-plugin-2.2.1.1.jarstruts2 namespace 注解
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;import com.opensymphony.xwork2.ActionSupport;@Namespace("/com")
@Action(value = "testStru2",
results = { @Result(
name = "success",
location = "/hello.jsp") })public class TestStru2Action extends ActionSupport{
public String execute(){
System.out.println("=========");
return SUCCESS;
}
public String test1(){
System.out.println("=========1");
return SUCCESS;
}
}
struts.xml:<?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.enable.DynamicMethodInvocation" value="false"
/> <constant name="struts.devMode" value="false" /> <include
file="example.xml"/> <package name="default" namespace="/"
extends="struts-default"> <default-action-ref name="index" /> <action
name="index"> <result type="redirectAction"> <param
name="actionName">HelloWorld</param> <param
name="namespace">/example</param> </result> </action> </package>
-->
<!-- 开发模式 value设置为true -->
<constant name="struts.devMode" value="true" />
<constant name="struts.configuration.xml.reload" value="true"/>
<constant name="actionPackages" value="com.test" />
<package name="hello" extends="struts-default">
</package>
</struts>
web.xml:<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
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_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>actionpackage</param-name>
<param-value>com.test</param-value>
</init-param>
</filter> <filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>hello.jsp</welcome-file>
</welcome-file-list>
</web-app>
lib:
commons-fileupload-1.2.1.jar,
commons-io-1.3.2.jar,
freeer-2.3.16.jar。
javassist-3.7.ga.jar,
ognl-3.0.jar,
struts2-core-2.2.1.1.jar,
xwork-core-2.2.1.1.jar,
struts2-convention-plugin-2.2.1.1.jar,
struts2-config-browser-plugin-2.2.1.1.jarstruts2 namespace 注解
解决方案 »
- CVS库迁移,内存溢出,向各位大噶求教。
- 初学整合ssh2异常,请教各位朋友是什么问题。
- 我的eclipse是日文版的听说集成多国语言包想要英文的如何改?
- 初学者求助大神一个问题
- 提问,关于struts+spring配置单例、原型的问题
- 关于HIBERNATE自动生成代码问题!
- http请求参数长度问题
- logic:iterate怎么用,看了之前得帖子还是不明白.
- 我的tomcat的奇怪问题
- 高分求:如何用java对XML中的QName数据类型做合法验证,要求源码(500分,人格担保)
- 一个java.sql.Connection可以被共享吗
- java timestamp类型存入oracle date字段问题
这一行编译不通过么?
看你的lib应该包含了,是否build path,讲lib加入到类路径中?
这样呢
http://www.cnblogs.com/fpjason/archive/2009/08/01/1536671.html
import没报错?那怎么会编译不通过呢。。
import没报错?那怎么会编译不通过呢。。编译肯定没问题哦~~
访问的时候找不到
There is no Action mapped for namespace [/com/test] and action name [testStru2] associated with context path [/testStruts2]. - [unknown location]
import没报错?那怎么会编译不通过呢。。编译肯定没问题哦~~
访问的时候找不到
There is no Action mapped for namespace [/com/test] and action name [testStru2] associated with context path [/testStruts2]. - [unknown location] 看到你的错误没?
There is no Action mapped for namespace [/com/test]
说的是没有找到命名空间:/com/test
而你这个类上面命名空间定义的是:@Namespace("/com")
明显明明空间对应不上了,怎么能访问呢!
import没报错?那怎么会编译不通过呢。。编译肯定没问题哦~~
访问的时候找不到
There is no Action mapped for namespace [/com/test] and action name [testStru2] associated with context path [/testStruts2]. - [unknown location] 看到你的错误没?
There is no Action mapped for namespace [/com/test]
说的是没有找到命名空间:/com/test
而你这个类上面命名空间定义的是:@Namespace("/com")
明显明明空间对应不上了,怎么能访问呢!
不是 这个是后面加的 相信我这个低级错误还是不会犯的
import没报错?那怎么会编译不通过呢。。编译肯定没问题哦~~
访问的时候找不到
There is no Action mapped for namespace [/com/test] and action name [testStru2] associated with context path [/testStruts2]. - [unknown location] 看到你的错误没?
There is no Action mapped for namespace [/com/test]
说的是没有找到命名空间:/com/test
而你这个类上面命名空间定义的是:@Namespace("/com")
明显明明空间对应不上了,怎么能访问呢!
不是 这个是后面加的 相信我这个低级错误还是不会犯的
那相关使用Action的jsp或配置文件发出来看看呗?