2009-05-30 5 views

답변

1
<jsp:useBean id="test" class="java.lang.String" scope="request"/> 

<% 
     test = "false"; 
%> 

1. outside scriptlet: <c:out value="${test}"/> <!-- will not print anything --> 

<% 
    out.println("2. in scriptlet: " + test);  // will print false 
%> 

<c:set var="test" value="true" /> 

3. outside scriptlet: <c:out value="${test}"/> <!-- will print true --> 

<% 
    out.println("4. in scriptlet: " + test);  // will print false 
%> 
4

요청 개체를 사용하여 작업 변수를 가져올 수도 있습니다. 당신이 행동에 변수 String userName이있는 경우 우리가 JSP 파일에 정의 된 변수의 값을 얻기위한 여분의 빈을 추가해야하는 이유 예를 들어,

<% 
String userName = (String) request.getAttribute("userName"); 
%> 
2

예,

<s:set var="jspVariable" value="%{strutsVariable}"/> 
<jsp:useBean id="jspVariable" type="com.example.Object" /> 
<%=jspVariable%> 
+0

을 사용할 수 있습니다 ? – Sourabh

관련 문제