struts2框架通配符报错HTTP Status 404要怎么调整,struts2404,struts.xml

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="helloworld_*" method="{1}" class="com.imooc.action.HelloWorldAction">            <result>/result.jsp</result>            <result name="{1}">/{1}.jsp</result>        </action>    </package></struts>

HelloWorldAction.java

package com.imooc.action;import com.opensymphony.xwork2.ActionSupport;public class HelloWorldAction extends ActionSupport {        public String execute() throws Exception{        System.out.println("执行action");        return SUCCESS;    }        public String add(){        System.out.println("add");        return SUCCESS;    }    }
http://127.0.0.1:8080/HelloWorld/helloworld_add.action
HTTP Status 404 - There is no Action mapped for namespace [/] and action name [helloworld_add] associated with context path [/HelloWorld].

报这个错误。。我明明是按照教程的写的啊?哪里出错了?

下划线改成中横线试试, 这个框架BUG众多,注意安全。

namespace是不是应该为/HelloWorld

编橙之家文章,

评论关闭