如果web.xml中这样配置:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
而在根目录下没有index.html,而是index.jsp,那么,会出现下面错误:
Struts has detected an unhandled exception:
Messages: There is no Action mapped for namespace [/] and action name [] associated with context path [/struts2_valueStack].
注意下面的action没有实现SessionAware接口:
public String execute() throws Exception {
ValueStack stack = ActionContext.getContext().getValueStack();
Map<String, Object> context = new HashMap<String, Object>();
context.put("key1", new String("This is key1"));
context.put("key2", new String("This is key2"));
stack.push(context);
System.out.println("Size of the valueStack: " + stack.size());
return "success";
}
原文: http://www.tutorialspoint.com/struts_2/struts_value_stack_ognl.htm
源代码:http://pan.baidu.com/share/link?shareid=194521980&uk=3878681452