Wie im Titel erwähnt, ich brauche einen Dienst in meinem page.jsp autowire .. "ich weiß, dass es nicht empfehlenswert ist"Wie autuedired Feder Service in ein JSP?
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="org.springframework.context.ApplicationContext"%>
<%@ page
import="org.springframework.web.servlet.support.RequestContextUtils"%>
<%@ page import="com.fussa.fyby.service.Test"%>
<%@ page import="com.fussa.fyby.model.PIL_P_APPLCTN"%>
<%
ApplicationContext ac = RequestContextUtils.getWebApplicationContext(request);
Test s = (Test) ac.getBean("fussafyby");
PIL_P_APPLCTN app = s.getByKey(13);
%>
<c:out value="azeerty"></c:out>
<c:out value="${ app.APPLCTN_CD }"></c:out>
<select name="listeGroupes" id="listeGroupes">
<option value="123">123</option>
<option value="${ app.APPLCTN_CD }">${ app.APPLCTN_CD }</option>
<option value="123">${ s.afficher() }</option>
</select>
Mein Service:
@Component("fussafyby")
@Transactional
public class Test {
@Autowired
private SessionFactory sessionFactory;
protected Session getSession() {
return sessionFactory.getCurrentSession();
}
public PIL_P_APPLCTN getByKey(int key) {
return (PIL_P_APPLCTN) getSession().get(PIL_P_APPLCTN.class, key);
}
public String affiche() {
return "FuSsA";
}
}
Nur azeerty Nachricht und Option in der Auswahl werden .. gezeigt
Vielen Dank für irgendwelche Hinweise ..
haben Sie meine Antwort überprüft verwenden kann? –