JSPからSpringを使う
普通そういうことはしないのだが、ちょっとしたトライandエラーに使うと便利な時があるかもしれない。
<%@page contentType="text/html"%>
<%
org.springframework.web.context.WebApplicationContext wac =
org.springframework.web.context.support.
WebApplicationContextUtils.getRequiredWebApplicationContext(
pageContext.getServletContext());
com.acme.MyBean myBean = (com.acme.MyBean)wac.getBean("myBean");
%>
<html>
<body>
ここで myBeanを使っていろいろやる
</body>
</html>
<%@page contentType="text/html"%>
<%
org.springframework.web.context.WebApplicationContext wac =
org.springframework.web.context.support.
WebApplicationContextUtils.getRequiredWebApplicationContext(
pageContext.getServletContext());
com.acme.MyBean myBean = (com.acme.MyBean)wac.getBean("myBean");
%>
<html>
<body>
ここで myBeanを使っていろいろやる
</body>
</html>
ラベル: Spring

0 件のコメント:
コメントを投稿
<< ホーム