1

request.setAttribute と request.getAttribute を使用するときに、このフォーラム自体を読みました

その値は、j​​sp ページがロードされるまで保持されます。そのため、彼らは隠しフォームを使用することを提案しました。私がその隠しフォームを使用しているとき、私はそれを正しく理解できないようです。.setAttribute を介して保存されているすべての値に初期化された値があることを確認している void 値には許可されていないと言われています。

ここにエラーが表示されたコードがあります

     **org.apache.jasper.JasperException: Unable to compile class for JSP: 

     An error occurred at line: 83 in the jsp file: /season1.jsp
     The method print(boolean) in the type JspWriter is not applicable for the arguments (void)
     80:   <!-- end .content --></div>
     81:   </form>
     82:   <%i=1;%>
     83:   <input type="hidden" name="epnostorage" value="<%= request.setAttribute("epno", epno) %>" />
     84:   <input type="hidden" name="casestorage" value="<%= request.setAttribute("case", i) %>" />
     85:   <%
     86:   }


     An error occurred at line: 84 in the jsp file: /season1.jsp
     The method print(boolean) in the type JspWriter is not applicable for the arguments (void)
     81:   </form>
     82:   <%i=1;%>
     83:   <input type="hidden" name="epnostorage" value="<%= request.setAttribute("epno", epno) %>" />
     84:   <input type="hidden" name="casestorage" value="<%= request.setAttribute("case", i) %>" />
     85:   <%
     86:   }
     87: else if(i==1)


     **
4

3 に答える 3

1

セッションは、値を格納する 1 つの方法です。

session.setAttribute("name",value);
于 2013-06-22T05:11:15.440 に答える
0

メソッドServletRequest.setAttribute(String, Object)void(何も返さない) なので、<%= ... %>使用しているタグに埋め込む値はありません。getAttribute、またはおそらくより簡潔な${varname}構文が必要だと思います。

于 2013-06-22T05:07:50.477 に答える