您好,我正在为 struts2.2.1 做约定 插件,使用 netbeans6.9 的示例,似乎有问题。我什至复制/粘贴所有内容,什么都没有。现在我得到:
“错误消息是 ${message} ”应该是
“错误信息是 Hello World”
我无法发布结构,但我按照教程将 jsp 放在 WEB-INF 下,但什么也没有
web.xml
<web-app>
<display-name>My Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>hello-world.jsp</welcome-file>
</welcome-file-list>
我的行动:
package com.example.actions;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport {
private String message;
public String getMessage() {
return message;
}
public String execute() {
if (System.currentTimeMillis() % 2 == 0) {
message = "It's 0";
return "zero";
}
message = "It's 1";
return SUCCESS;
}
}
你好世界.jsp
<html>
<body>
The Error message is ${message}
</body>
</html>
我认为我不需要 strut.xml 文件。我真的很沮丧,真的很感激任何帮助,或者你不能用 struts2.2.1 做注释吗?