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>
<package name="struts" extends="struts-default">
<action name="HelloWorld" class="test.HelloWorld">
<result>/showhelloworld.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_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Struts2Example10</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>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
class
package test;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 3014483748547141238L;
String message = "";
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public String execute() throws Exception {
message = "held";
return SUCCESS;
}
}
.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>大家好啊。</title>
</head>
<body>
<form action="HelloWorld.do" method="post">
<input type="submit" value="确定">
${message}
</form>
</body>
</html>
点击按钮的页面
直接到这个页面
错误很明显啊,哥们,你的环境变量
was not found on the java.library.path:
引用来自“红薯”的答案
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: G:\java\eclipse-jee-indigo-SR1-win32\eclipse\jre\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;G:/java/eclipse-jee-indigo-SR1-win32/eclipse/jre/bin/client;G:/java/eclipse-jee-indigo-SR1-win32/eclipse/jre/bin;G:/java/eclipse-jee-indigo-SR1-win32/eclipse/jre/lib/i386;C:\Program Files\Intel\iCLS Client\;C:\Program Files\AuthenTec TrueSuite\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\ThinkPad\Bluetooth Software\;C:\Program Files\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files\SinoVoice\jTTS 5.0 Desktop\Bin.;G:\java\jdk1.6.0_02C:\Program Files\Java\jdk1.7.0_01\bin;C:\Program Files\MySQL\MySQL Server 5.0\bin;%Catalina%\bin;%Catalina%\lib;G:\java\jdk1.6.0_02\bin;G:\java\jdk1.6.0_02\lib;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;G:\java\eclipse-jee-indigo-SR1-win32\eclipse;
2013-4-1 22:11:02 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Struts2Ex1' did not find a matching property.
2013-4-1 22:11:02 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:WageIS_Servlet' did not find a matching property.
2013-4-1 22:11:05 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8080"]
2013-4-1 22:11:05 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-bio-8009"]
2013-4-1 22:11:05 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 5362 ms
2013-4-1 22:11:06 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
2013-4-1 22:11:06 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.30
2013-4-1 22:11:08 org.apache.catalina.util.SessionIdGenerator createSecureRandom
信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [367] milliseconds.
2013-4-1 22:11:09 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(G:\java\program\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\WageIS_Servlet\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class