首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

there is no action 地图ped for namespace/ and action name

2012-08-02 
there is no action mapped for namespace/ and action name这是struts.xml代码?xml version1.0 encod

there is no action mapped for namespace/ and action name

这是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>

??? <constant name="struts.enable.DynamicMethodInvocation" value="false" />
??? <constant name="struts.devMode" value="false" />

??? <package name="default" extends="struts-default">

??????? <default-action-ref name="index" />

??????? <global-results>
??????????? <result name="error">/error.jsp</result>
??????? </global-results>

??????? <global-exception-mappings>
??????????? <exception-mapping exception="java.lang.Exception" result="error"/>
??????? </global-exception-mappings>

??????? <!--<action name="login">
??????????? <result type="com.laoa.struts.action.MethodAction">
??????????????? <param name="nameAction"></param>
??????????????? <param name="namespace">/com/laoa/struts/action</param>
??????????? </result>
??????? </action> -->
??????? <action name="login" method="login">
??????? <result name="success">ok.jsp</result>
??????? <result name="input">login.jsp</result>
??????? </action>
??? </package>

??? <include file="example.xml"/>

??? <!-- Add packages here -->

</struts>

MethodAction代码

package com.laoa.struts.action;

import com.opensymphony.xwork2.ActionSupport;

public class MethodAction extends ActionSupport {
?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;
?}
?public String login() throws Exception {
??if(name.equals("java") && password.equals("java")){
???return SUCCESS;
??}
???else{
????return INPUT;
???}
?}
?public String add() throws Exception {
??return null;
??
?}
}

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.html</welcome-file>
??? </welcome-file-list>

</web-app>

login.jsp代码

<%@ page language="java" pageEncoding="GB2312"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<html>
? <body>
? <h1></h1>
? <s:form action="/MethodAction" method="post">
? <table border="0">
? <tr>
? <td><s:textfield label="姓名:" name="name"></s:textfield></td>
? </tr>
? <tr>
? <td><s:textfield label="密码:" name="password"></s:textfield></td>
? </tr>
? <tr align="center">
? <td >
? <s:submit></s:submit><s:reset></s:reset>
? </td>
? </tr>
? </table>
? </s:form>
? </body>
</html>

请哪位仁兄给帮帮忙,我用得是Myeclipse6.0+Tomcat6.0+jdk6.0+struts2.2.3.1

2 楼 laoaenna 2011-10-26   该问题已经解决,针对struts2.2。*。*以后版本,

热点排行