亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

HTTP4.4錯誤 There is no Action mapped for namespace [/] and action name [hello] associated with context path [/StrutsDemo].

.opensymphony.xwork2.config.ConfigurationException: There is no Action mapped for namespace [/] and action name [hello] associated with context path [/StrutsDemo].
?? ?at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:192) ~[struts2-core-2.5.5.jar:2.5.5]
?? ?at org.apache.struts2.factory.StrutsActionProxy.prepare(StrutsActionProxy.java:63) ~[struts2-core-2.5.5.jar:2.5.5]
?? ?at org.apache.struts2.factory.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37) ~[struts2-core-2.5.5.jar:2.5.5]
?? ?at com.opensymphony.xwork2.Default

以上是錯誤信息,我用的是strtus2.5.5版本的,jar包都導入了,項目啟動是沒有問題的,只是在跳轉到相應的Action時報錯,我已經把目錄結構以及類的目錄都寫好了,名稱也都核對過了,還是有問題,麻煩大家幫忙看一下!

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" 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">
? <display-name>StrutsDemo</display-name>
?
? <filter>
? ?? ?<filter-name>struts2</filter-name>
? ?? ?<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
? </filter>
?
? <filter-mapping>
? ?? ?<filter-name>struts2</filter-name>
? ?? ?<url-pattern>/*</url-pattern>
? </filter-mapping>
?? ?
? <welcome-file-list>
??? <welcome-file>default.jsp</welcome-file>
? </welcome-file-list>
</web-app>

struts.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC
?? ?"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
?? ?"http://struts.apache.org/dtds/struts-2.5.dtd">

<struts>
?? ?<package name="default" namespace="/" extends="struts-default">
?? ??? ?<action name="hello" class="com.imooc.action.HelloAction">
?? ??? ??? ?<result name="success">/result.jsp</result> <!-- 默認name="success" -->????
?? ??? ?</action>
?? ?</package>
</struts>

default.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>default.jsp</title>
</head>
<body>
?? ?<h1>This is default.jsp!</h1>
?? ?<center>${tip}</center>
?? ?<form action="hello.action" method="post">
?? ??? ?用戶名:<input type="text" name="username" />
?? ??? ?密碼:<input type="text" name="password"/>
?? ??? ?<input type="submit" value="登錄"/>
?? ?</form>
</body>
</html>

HelloAction.class

package com.imooc.action;

import com.opensymphony.xwork2.ActionSupport;

public class HelloAction extends ActionSupport {

?? ?@Override
?? ?public String execute() throws Exception {
?? ??? ?System.out.println("Hello Action execute!");
?? ??? ?return SUCCESS;
?? ?}?? ?
}

我已經根據下面的提示查錯了,但是還是出錯。

1.struts.xml文件錯誤。

? ? 這種錯誤又分為以下幾種:

? ? 1)struts.xml文件名錯誤。一定要注意拼寫問題;

? ? 2)struts.xml文件放置路徑錯誤。一定要將此文件放置在src目錄下。編譯成功后,要確認是否編譯到classes目錄中;

? ? 3)struts.xml文件內容錯誤:啟動頁面一定要是自己工程里有的jsp文件。

? ? ?<welcome-file-list>?
? ? ?<welcome-file>index.jsp</welcome-file>?
? ? ?</welcome-file-list>

? ? 如果你在Eclipse工程的WebContent文件夾下沒有這個index.jsp文件,也會報同樣的錯誤。
? ? 比如我自己定義了一個login.jsp文件,放在WebContent文件夾下,就寫成
? ? <welcome-file>login.jsp</welcome-file>?
? ? 把login.jsp文件放在WEB-INF下自定義的jsp文件夾下,就寫成
? ? <welcome-file>/WEB-INF/jsp/login.jsp</welcome-file>

2.表單提交頁面的錯誤





正在回答

1 回答

filter里面看看

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

HTTP4.4錯誤 There is no Action mapped for namespace [/] and action name [hello] associated with context path [/StrutsDemo].

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號