次のように、JSP で有効な SQL ステートメントを使用したいと考えています。
<sql:query var="test" dataSource="DL">
select p.name name, j.description job_description, d.description department_description
from person as p, job as j, department as d
where ...
</sql:query>
3 つのテーブルに参加しているため、「説明」という 2 つの重複した名前があります。これは通常、これらのフィールド名のエイリアスを使用して SQL で解決します。JSP では、これは正しく処理されません。別名を介して結果セットにアクセスできず、"説明" のみが利用可能ですが、"job_description" または "department_description" は利用できません。
これは不十分です:
<c:forEach var="row" items="${test.rows}">
${row.description}
</c:forEach>
これはまったく機能しません:
<c:forEach var="row" items="${test.rows}">
${row.job_description}
</c:forEach>
この問題の解決策はありますか (これはバグです)?
これは私の context.xml です:
<Context path="/test" docBase="test" reloadable="true" crossContext="true">
<Resource
name="DL"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="xxx"
password="xxx"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test"/>
</Context>