我是struts和jsp的新手。 目前我被困在上述錯誤,它從最後兩個星期嚴重搞砸了我,不知道我做錯了什麼。 這裏就是我試圖做的事:Struts錯誤:沒有爲命名空間/和動作名稱映射的操作***
temp.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>Sample Page</title>
</head>
<body>
Hello World
<br/>
<A href="myAction.action"><font face="arial" color="black" size=2>Run</font></A>
</body>
</html>
在這個頁面中,我有HREF鏈接「運行」,當我點擊這個鏈接,它會調用我的行動並最終調用我的測試.jsp頁面。
test.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>Insert title here</title>
</head>
<body>
!!!! Hello !!!!
</body>
</html>
struts.xml的
<?xml version="1.0" encoding="UTF-8"?>
<struts>
<constant name="struts.devMode" value="true" />
<package name="TestWeb" extends="struts-default" namespace="/">
<action name="myAction">
<result>/test.jsp</result></action></package>
</struts>
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>TestWeb</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.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
朋友,請幫助我。
向我們展示struts.xml。和你正在打的網址。在問題中包含更多細節。 –
使用** code **按鈕('{}'one)並請...縮進您的html:/ –
您的Struts 2配置文件格式錯誤。您正在使用棄用的過濾器。你是否部署到根上下文?如果不是,則應在URL中包含應用上下文。當框架附帶示例時,兩個星期才能獲得一個可用的應用程序? –