基于struts2的一个小动作问题 [英] a little question of action based on struts2
问题描述
朋友们!我正在通过 vaannila 的 Struts 2 Spring 集成,在运行应用程序时,我对成功.jsp 感到困惑,文件的一部分如下所示:
<块引用> ${message}
按照教程一步步萌芽后,tomcat启动时,浏览器显示正是success.jsp ${message} 的内容.但从逻辑上讲,它应该表明Spring 强大的依赖注入功能.我检查了配置,如:
- 动作(这里是helloWorld.action)
- 该类真正执行操作所需的操作(这里是 HelloWorld.java)
行动与工人阶级之间的联系
applicationContext.xml 做配置 spring bean 之类的
struts.xml 命名了一个名为
<块引用>helloWolrd
的动作,用于引用 applicationContext.xml 中定义的 beanhelloWorldClass
喜欢:<结果名称="成功">/success.jsp</result></动作>
但似乎 applicationcontext.xml 中定义的用于显示 DependancyInjection 的 bean 属性不起作用,为什么?
${message} 应该可以工作.看起来您的 jsp 无法解析 EL.首先检查您的jsp 是否可以解析EL.试试 ${1+2}.如果直接在浏览器上打印,请在您的jsp页面顶部添加以下内容.
<%@ page isELIgnored="false"%>
你也可以使用这个!
friends! I am learning struts2 framework by vaannila's Struts 2 Spring Integration ,In running the application, I am confused by the success.jsp ,part of the file like below:
<body>
${message}
</body>
after step by step buding followed the tutorial, when tomcat fire up, the brower shows just what lies in of success.jsp ${message} .But logically it should indicate Spring's powerful Dependency Injection feature. I checked the configuration like:
- The action (here is helloWorld.action)
- The class really do what action requires (here is HelloWorld.java)
the link between action and working class
applicationContext.xml do configured spring bean like
<bean id="helloWorldClass" class="com.vaannila.HelloWorld" > <property name="message" value="Hello World!" /> </bean>
struts.xml do named a action called
helloWolrd
for referring to the beanhelloWorldClass
which defined in applicationContext.xml like:<action name="helloWorld" class="helloWorldClass"> <result name="SUCCESS">/success.jsp</result> </action>
but it seemed that the bean property for showing DependancyInjection which defined in applicationcontext.xml DID NOT WORK, why?
${message} should work. Looks like your jsp is unable to parse EL. Check first if your jsp can parse EL. Try with ${1+2}. If it prints directly on the browser, add the following on the top of your jsp page.
<%@ page isELIgnored="false"%>
You can also want to use this !
<s:property value="message"/>
这篇关于基于struts2的一个小动作问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!