以前都用myeclipse的,现在换成eclipse感觉各种纠结。。
弄了半天了还是这个错误。。求助。。
或者发个eclipse struts2的例子给我也行~~
struts2.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>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<package name="default" namespace="/" extends="struts-default">
<action name="user" class="service.myAction">
<result name="login_success">/NewFile.jsp</result>
<result name="login_failure">/index.jsp</result>
</action>
</package>
</struts>
ACTION的java代码
package service;
import com.opensymphony.xwork2.ActionSupport;
public class myAction extends ActionSupport{
public String login() throws Exception{
if(name=="111"&&password=="111"){
return "login_success";
}
return "login_failure";
}
private String name;
private String password;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" 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>Struts Blank</display-name>
<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>
jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!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>Insert title here</title>
</head>
<body>
<s:if test="#session.fullname==null">
<form action="user!login.Action">
<input name="name" type="text" />
<input name="password" type="password" />
<input type="submit" />
</form>
</s:if>
<s:else>
</s:else>
</body>
</html>
哎。。弄了又弄了很久,还是这样,算了,大家谁给发我一个eclipse的小例子。。我的邮箱ismycy@qq.com
我这么改后是这样的哦
虽然还是404不过变了一高级一些。。会不会是好兆头。。。那个包我把struts2-blank里面的都复制到lib里面了。。
算了,给你发一个吧。我按照你的代码敲的,怎么可能有错呢。你修改完配置文件记得重启服务器。要不然就会报错。
本回答被提问者采纳There is no Action mapped for namespace [/] and action name
警告: No configuration found for the specified action: 'user!login' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
警告: No configuration found for the specified action: 'user!login' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
警告: Could not find action or result