Struts2 我的属性不是struts 2.0中jsp上的格式副本

Struts2 我的属性不是struts 2.0中jsp上的格式副本,struts2,Struts2,我在Action类中设置了一个属性,如下所示 public class HelloWorld{ public String execute() { ANNOTATION #1 setCustomGreeting( GREETING + getName() ); return "SUCCESS"; } private String customGreeting; public String getCustomGreeting() { return custom

我在Action类中设置了一个属性,如下所示

public class HelloWorld{
  public String execute() { ANNOTATION #1
  setCustomGreeting( GREETING + getName() );
  return "SUCCESS"; 
  }
  private String customGreeting;
  public String getCustomGreeting()
  {
    return customGreeting;
  }
  public void setCustomGreeting( String customGreeting ){
  this.customGreeting = customGreeting;
}
}
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>HelloWorld</title>
</head>
<body>
<h3>Custom Greeting Page</h3>
<h4><s:property value="customGreeting"/></h4> 
</body>
</html>
我试图在jsp上呈现它,如下所示

public class HelloWorld{
  public String execute() { ANNOTATION #1
  setCustomGreeting( GREETING + getName() );
  return "SUCCESS"; 
  }
  private String customGreeting;
  public String getCustomGreeting()
  {
    return customGreeting;
  }
  public void setCustomGreeting( String customGreeting ){
  this.customGreeting = customGreeting;
}
}
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>HelloWorld</title>
</head>
<body>
<h3>Custom Greeting Page</h3>
<h4><s:property value="customGreeting"/></h4> 
</body>
</html>

你好世界
自定义问候页
但是它没有在jsp上打印任何内容,请帮助我?

您的代码看起来很好

您是否直接调用JSP

您的操作是否映射到struts.xml中?

调试建议:

  • 在方法中放置断点(或跟踪语句,或其他内容),以确认是否调用它们
  • 在页面上放置一个标签
  • 如果这没有给出任何提示,那么启用更详细的日志记录(如何做到这一点将取决于正在使用的日志记录框架),特别是针对OGNL

是的,我的操作被映射到struts.xml中,目标jsp上的其他内容被正确显示,但问题只是您是否在地址url中打开jsp页面或操作?