struts taglib:在jsp中设置请求参数

时间:2013-08-22 15:10:27

标签: jsp struts-1 struts-action

我在页面上用两个按钮迭代一个新闻列表:编辑和查看,所以我想设置新闻ID以请求使用它然后在编辑操作中,这里是表格

<html:form action="NewsAction">
        <div class="news">
            <fieldset>
                <logic:iterate name="newsList" id="news">
                    <legend>
                        <bean:write name="news" property="newsTitle" />
                    </legend>
                    <p>
                        <bean:write name="news" property="newsId"/>
                        <bean:write name="news" property="newsTitle" />

                        <bean:write name="news" property="newsBrief" />
                        <bean:write name="news" property="newsDate" />
                    </p>


                    <html:submit property="method">view</html:submit>
                    <html:submit property="method" value="edit" />
                    <html:submit property="method">delete</html:submit>
                </logic:iterate>

            </fieldset>
        </div>
    </html:form>

我试过<html:hidden property="nnews" value="${news.newsId}" />

<jsp:setProperty property="newsId" name="news" param="newsInstanceId" />

使用第一个我在请求参数中获得$ {news.newsId},并使用第二个空值

2 个答案:

答案 0 :(得分:1)

问题似乎已经解决了:我在web.xml版本2.5(它是2.3)中声明了

<web-app 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="Your_WebApp_ID"
    version="2.5">

并添加到@page isELIgnored =&#34; false&#34;

答案 1 :(得分:-1)

关于你的第一个方法:

更改此行:

<html:hidden property="nnews" value="${news.newsId}" />

收件人:

 <html:hidden property="nnews" value="<bean:write name="news" property="newsId"/>" />