jsp页面代码:<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:form action="TestAction" > //************就是这行***************
Name: <s:textfield name="name" />
<s:submit label="submit"> </s:submit>
</s:form>
</body>
</html>struts.xml配置文件:
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default.xml"/>
<package name="test" extends="struts-default">
<action name="TestAction" class="test.MyTest">
<result>print.jsp</result>
</action>
</package>
</struts>问题:
就是打注释的那行有问题(有个红差差),说什么“The value [TestAction] for attribute [action] in tag [form] is not valid.”
在网上查了一下,有人说有个红差不要紧也能跑,我就去试了一下,
结果:
HTTP Status 404 - /myTest/TestAction--------------------------------------------------------------------------------type Status reportmessage /myTest/TestActiondescription The requested resource (/myTest/TestAction) is not available.小弟刚刚才开始学struts2所以遇上这个问题怎么解就解决不了,希望达人们能指点一下,谢了。
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:form action="TestAction" > //************就是这行***************
Name: <s:textfield name="name" />
<s:submit label="submit"> </s:submit>
</s:form>
</body>
</html>struts.xml配置文件:
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default.xml"/>
<package name="test" extends="struts-default">
<action name="TestAction" class="test.MyTest">
<result>print.jsp</result>
</action>
</package>
</struts>问题:
就是打注释的那行有问题(有个红差差),说什么“The value [TestAction] for attribute [action] in tag [form] is not valid.”
在网上查了一下,有人说有个红差不要紧也能跑,我就去试了一下,
结果:
HTTP Status 404 - /myTest/TestAction--------------------------------------------------------------------------------type Status reportmessage /myTest/TestActiondescription The requested resource (/myTest/TestAction) is not available.小弟刚刚才开始学struts2所以遇上这个问题怎么解就解决不了,希望达人们能指点一下,谢了。
The value [TestAction.action] for attribute [action] in tag [form] is not valid.
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default.xml"/>
<package name="test" extends="struts-default">
<action name="TestAction" class="test.MyTest">
<result>print.jsp</result>
</action>
</package>
</struts>是这个吗?我只想先试一个跳转所以就写了这么多
这位前辈,我已经按你说的改好了,可是运行的时候还是这样的报错:
HTTP Status 404 - /myTest/TestAction--------------------------------------------------------------------------------type Status reportmessage /myTest/TestActiondescription The requested resource (/myTest/TestAction) is not available.
配置过滤器没有??
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>myTest</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <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>
</web-app>
HTTP Status 404 - /myTest/TestAction--------------------------------------------------------------------------------type Status reportmessage /myTest/TestActiondescription The requested resource (/myTest/TestAction) is not available.这样,对了,标签的版本会不会有问题呢,我的struts2是struts-2.0.9的,开发的IDE是ObjectWeb Lomboz for JavaEE Development Version: 3.3的
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String execute() {
name = "Hello, " + name + "!";
return SUCCESS;
}
}
commons-logging-api-1.1
freeer-2.3.8
ognl-2.6.11
struts2-core-2.0.9
xwork-2.0.4我的QQ:254728713
真可爱。。