-1
我正在實施一個小的struts 2 web應用程序,而我得到上述異常我是struts 2的新手。我已經看到來自堆棧上的流和其他網站的一些建議。我嘗試了所有的建議,但仍然無法解決我的問題。沒有爲命名空間/和操作名稱映射的操作。 - [未知位置]
這裏是我的strust.xml並保存在WEB-INF/clasess中。
<struts>
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<action name="Login">
<result>pages/login.jsp</result>
</action>
<action name="Welcome" class="com.tcs.action.DemoAction">
<result name="SUCCESS">pages/welcome.jsp</result>
</action>
</package>
</struts>
這裏是我的動作類。
package com.tcs.action;
public class DemoAction {
private String userName;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String execute(){
return "SUCCESS";
}
}
我不停的login.jsp和的welcome.jsp內的webapp/pages文件夾 這裏是我的login.jsp
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head></head>
<body>
<h1>Struts 2 Hello World Example</h1>
<s:form action="Welcome">
<s:textfield name="userName" label="Username" />
<s:submit />
</s:form>
</body>
</html>
和的welcome.jsp
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head></head>
<body>
<h1>Struts 2 Hello World Example</h1>
<h2>
Hello
<s:property value="userName" />
</h2>
</body>
</html>
和我希望我添加了所有與struts相關的jar,因爲我沒有找到任何未找到的類或沒有找到類def的異常。 我希望我在很多地方問我已經存在的問題,但我仍然沒有解決問題。
也在您的 login.jsp中包含相同的名稱空間屬性。 –
Abhay
你的意思是「/」我喜歡這個,但我仍然得到同樣的問題 – suri