逍遥兮容与 2011-08-16 13:20 采纳率: 100%
浏览 223
已采纳

提交后就报这个错:The requested resource (There is no Action mapped for action name Sum.)

The requested resource (There is no Action mapped for action name Sum.) is not available.

下面是代码,很简单的,提示是说没这个映射,麻烦把为什么这样改说下,谢谢
目录:
[img]http://dl.iteye.com/upload/attachment/537165/b3d62be5-0cbd-3cf4-a7e2-aaf56e543c79.jpg[/img]

struts.xml
[code="java"]<?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">



/page/positive.jsp
/page/negative.jsp


[/code]

web.xml
[code="java"]<?xml version="1.0" encoding="UTF-8"?>
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">
Spec Builder

struts2

org.apache.struts2.dispatcher.FilterDispatcher




struts2
/*


[/code]

sum.jsp
[code="java"]<%@ page language="java" import="java.util.*" pageEncoding="GBK" %>
<%@ taglib prefix="s" uri="/struts-tags"%>


输入操作数
  <body>
       求代数和
      <br/>
      <s:form action="Sum">                
          <s:textfield name="operand1" label=" 操作数1"/>
          <s:textfield name="operand2"  label=" 操作数2" />        
          <s:submit value="代数和" />            
      </s:form>
  </body>

[/code]

FirstAction.java
[code="java"]package action;

import com.opensymphony.xwork2.ActionSupport;

public class FirstAction extends ActionSupport
{
private int operand1;
private int operand2;

public String execute() throws Exception
{
    if (getSum() >= 0)  // 如果代码数和是非负整数,跳到positive.jsp页面
    {
        return "positive";
    }
    else  // 如果代码数和是负整数,跳到negative.jsp页面
    {
        return "negative";
    }
}

public int getOperand1()
{
    return operand1;
}

public void setOperand1(int operand1)
{
    System.out.println(operand1);
      this.operand1 = operand1;
}

public int getOperand2()
{
    return operand2;
}  
public void setOperand2(int operand2)
{
    System.out.println(operand2);
    this.operand2 = operand2;
}
public int getSum()
{
    return operand1 + operand2;  // 计算两个整数的代码数和
}

}
[/code]

  • 写回答

1条回答 默认 最新

  • weixin_42317583 2011-08-16 16:39
    关注

    你这个URL生成没有命名空间是../Sum.action





    /page/positive.jsp

    /page/negative.jsp




    你这个要../struts2/Sum.action才能访问到吧

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题