后台执行方法,网页报404错误

来源:4-4 动态方法调用-深入Struts2

王飞燕

2016-06-09 11:47

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.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="add">/{1}.jsp</result>

<result name="update">/{1}.jsp</result>

</action>


</package>

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

</struts>    

package com.imooc.action;


import com.opensymphony.xwork2.ActionSupport;


public class HelloWorldAction extends ActionSupport{

@Override

public String execute() throws Exception {

System.out.println("执行Action");

return SUCCESS;

}

public String add(){

System.out.println("执行add");

return "add";

}

public String update(){

System.out.println("执行upate");

return "update";

}

}

HTTP Status 404 - /HelloWorld/add.jsp

type Status report

message /HelloWorld/add.jsp

description The requested resource is not available.


写回答 关注

1回答

  • weibo_sJ书桀
    2016-06-11 14:48:18

    浏览器地址栏应该这样输入:127.0.0.1:8080/你的工程名/helloworld_add

Struts2入门

本教程带你踏上Struts2学习之旅,对Struts2进行更深入讲解

95062 学习 · 456 问题

查看课程

相似问题