为什么我的struts的hellworld.do不可访问??

森罗万象t 发布于 2013/03/31 09:06
阅读 358
收藏 1

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>

点击按钮的页面

直接到这个页面



加载中
0
首席安全砖家
首席安全砖家

错误很明显啊,哥们,你的环境变量

 was not found on the java.library.path:

0
红薯
红薯
这种情况错误信息比源码更重要,“不可访问” 应该有具体的现象和异常
森罗万象t
森罗万象t
也就是郁闷 ,很久以前的做过成功了的,仅仅是换了个电脑。eclipse还是原来的,测试的包也一样,时隔几个月就出问题了
0
not_empty
not_empty
HelloWorld.action
森罗万象t
森罗万象t
把helloworld.do的后缀改为。action是可以访问的。但是我点击确定他自动跳转到了helloworld.do而不是。action
0
zplswf
zplswf
 <constant name="struts.action.extension" value="do,action" />你可以配置下这个属性
森罗万象t
森罗万象t
就是那个.java
森罗万象t
森罗万象t
试了 ,el语言还是没能显示出struts中的东西
森罗万象t
森罗万象t
试了下 ,还是不行
0
森罗万象t
森罗万象t

引用来自“红薯”的答案

这种情况错误信息比源码更重要,“不可访问” 应该有具体的现象和异常
2013-4-1 22:11:02 org.apache.catalina.core.AprLifecycleListener init
信息: 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
0
森罗万象t
森罗万象t
就是这个错误
0
森罗万象t
森罗万象t
哦 明白了。是因为我有几个jdk,偶环境变量设置的没有问题但是eclipse中的instal和设置的变量不是同一个jak,所以。。。。。
返回顶部
顶部