照着网上一个实例做的。
struts.xml
----------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant value="mess" name="struts.custom.i18n.resources"/>
<constant value="UTF-8" name="struts.i18n.encoding"/>
<package name="default" extends="struts-default" namespace="">
<action name="Hello" class="" >
<result name="input">hello.jsp</result>
</action>
</package>
</struts>
----------------------------------------------------------------------------
web.xml
-----------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<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_3_0.xsd" id="WebApp_ID" version="3.0">
<!-- 定义Struts2的核心Filter -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<!-- 让Struts2的核心Filter拦截所有请求 -->
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
------------------------------------------------------------------------------
hello.jsp
--------------------------------------------------------------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>Hello world</title>
</head>
<body>
Hello!
</body>
</html>
--------------------------------------------------------------------------
工程名为web 浏览器输入http://localhost:8080/web/Hello
出现下面的信息
No result defined for action com.opensymphony.xwork2.ActionSupport and result success
------最佳解决方案--------------------------------------------------------
不写java类可以把struts配置成这样:
<package name="default" extends="struts-default" namespace="/">
<action name="Hello" >
<result >hello.jsp</result>
</action>
</package>
------其他解决方案--------------------------------------------------------
struts要写一个action控制器啊。你都没有,当然错。
<action name="Hello" class="这里指明你的action实现类,比如:com.xx.HelloAction" >
------其他解决方案--------------------------------------------------------
你的java代码呢?把action 贴出来看看。。
------其他解决方案--------------------------------------------------------
没有 java代码啊。。
这个class属性不是为空吗