struts.xml文件<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<package name="example" namespace="/" extends="struts-default"> <action name="HelloWorld" class="example.HelloWorld">
<result name="success">/HelloWorld.jsp</result>
</action>
</package>
</struts>
import com.opensymphony.xwork2.ActionSupport;public class HelloWorld extends ActionSupport { public String execute() throws Exception {
setMessage("你好!Struts 2!");
return SUCCESS;
}
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
JSP页面<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title></title>
</head>
<body>
<h2>${message}</h2>
</body>
</html>
在浏览器上访问http://localhost:8080/webtest/HelloWorld显示
${message}
无法得到message 值但是可以用<s:property value="message"/>这个标签得到请问各位高人那里错了用到是STRTUS最小的包, xwork-2.1.2.jar,struts2-core-2.1.6.jar,spring-test-2.5.6.jar,ognl-2.6.11.jar,junit-3.8.1.jar,freeer-2.3.13.jar,commons-logging-1.1.jar,commons-io-1.3.2.jar,commons-fileupload-1.2.1.jar
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<package name="example" namespace="/" extends="struts-default"> <action name="HelloWorld" class="example.HelloWorld">
<result name="success">/HelloWorld.jsp</result>
</action>
</package>
</struts>
import com.opensymphony.xwork2.ActionSupport;public class HelloWorld extends ActionSupport { public String execute() throws Exception {
setMessage("你好!Struts 2!");
return SUCCESS;
}
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
JSP页面<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title></title>
</head>
<body>
<h2>${message}</h2>
</body>
</html>
在浏览器上访问http://localhost:8080/webtest/HelloWorld显示
${message}
无法得到message 值但是可以用<s:property value="message"/>这个标签得到请问各位高人那里错了用到是STRTUS最小的包, xwork-2.1.2.jar,struts2-core-2.1.6.jar,spring-test-2.5.6.jar,ognl-2.6.11.jar,junit-3.8.1.jar,freeer-2.3.13.jar,commons-logging-1.1.jar,commons-io-1.3.2.jar,commons-fileupload-1.2.1.jar
解决方案 »
- myeclipse中自动生成变量快捷键是ctrl+2,L 我想修改为其它快捷键 怎么设置比较好 不冲突啊
- 使用atomikos 配置的数据源,急 在线等
- spring整合hibernate时报错
- 在安装TortoiseSVN 时出现错误
- 高手帮忙看看,哪里出问题了
- tomcat怎么配置域名
- 请教一个SocketException(A system call received a parameter that is not valid.)
- 各位高手,帮我看看这段客户端程序是否有问题?
- 关于本地JNDI找不到的问题?谢谢各位
- 第一次发布EJB TO JBOSS的问题
- jsp 页面访问问题,初学者请指教,谢谢 ??
- java 等待进度条
在配置文件中,
<package name="struts-default" abstract="true">
</package>
有个freeer返回类型,改为默认就行
<result-type name="freeer" class="org.apache.struts2.views.freeer.FreeerResult" default="true"/>或者只改
struts.xml中,你写的配置文件,返回类型为freeer即可。
麻烦高人告诉我这个文件怎么改吧<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<package name="example" namespace="/" extends="struts-default"> <action name="HelloWorld" class="example.HelloWorld">
<result name="success">/HelloWorld.jsp</result>
</action>
</package>
</struts>
2. 在Struts 2配置文件中,引用OGNL表达式,如
<action name="AddPhoto" class="addPhoto">
<interceptor-ref name="fileUploadStack" />
<result type="redirect">ListPhotos.action?albumId=${albumId}</result>//通过action的getAlbumId()取值
</action>
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title><s:property value="message"/></title> //这里可以得到值
</head>
<body>
<h2>${message}</h2>//这里得不到值,原样显示为${message}
</body>
</html>我是照着书上的例子来做的,怎么也显示不了${message}
这种方式在JSP上不能用吗, 它是FREEMARKER的标签吗,是不是JSTL的
WEB.XML的版本问题需要在JSP头部加上<%@ page isELIgnored="false" %>