Domanda

For taghandlers like SimpleTagSupport or BodyTagSupport Autowired does not work, as tag are created for each individual request. Now if I need to call a method of a service class managed by Spring, how can I do that?

And isn't it a good design to call a service method from a taghandler? Shall I use some alternative approach?

È stato utile?

Soluzione

And isn't it a good design to call a service method from a taghandler?

Accordingly to Custom Tags in JSP Pages JSP technology also provides a mechanism for encapsulating other types of dynamic functionality in custom tags, which are extensions to the JSP language. Some examples of tasks that can be performed by custom tags include operating on implicit objects, processing forms, accessing databases and other enterprise services such as email and directories, and implementing flow control.

Shall I use some alternative approach?

You can either use the @Configurable Support or extend your tag from RequestContextAwareTag.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top