在struts中使用${},但是myeclipse中显示有错误:<?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"><struts>
<constant name="struts.devMode" value="true" />
<package name="user" namespace="/user" extends="struts-default">
<action name="user" class="com.wyz.UserAction">
<result type="redirect">/user.jsp?t=${type}</result>//错误在此行,加上$就显示错误!
</action>
</package>
</struts>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"><struts>
<constant name="struts.devMode" value="true" />
<package name="user" namespace="/user" extends="struts-default">
<action name="user" class="com.wyz.UserAction">
<result type="redirect">/user.jsp?t=${type}</result>//错误在此行,加上$就显示错误!
</action>
</package>
</struts>
跳转的地址如果有参数的话,可以用${yourParameter}表示参数,不过这个type要是你的class里面的一个字段,要有get,set方法的。所以检查下是不是你的类没有该get方法?
代码:
package com.wyz;import com.opensymphony.xwork2.ActionSupport;public class UserAction extends ActionSupport {
private int type;
public int getType() {
return type;
} public void setType(int type) {
this.type = type;
} public String execute() throws Exception {
return "success";
}}