在struts.xml中使用约定插件 [英] Using convention plugin with struts.xml

查看:93
本文介绍了在struts.xml中使用约定插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中使用约定插件,一切正常,直到需要添加自定义拦截器为止.要添加自定义拦截器,我需要在项目中包含struts.xml.但是,当我添加struts.xml时,每个页面都会出现404错误.我已经尝试过解决方案,但它似乎无法正常工作. 谢谢.

I'm using convention plugin in my project and everything was fine until I needed to add a custom Interceptor. To add a custom Interceptor I need to have struts.xml in my project. But when I add struts.xml, it gives me 404 error for every page. I have tried this solution but it doesn't seem to work. Thanks.

推荐答案

struts.xml配置文件应位于源文件夹中,例如srcresources.生成应用程序时,编译后的输出将定向到WEB-INF/classes.您可以在部署或使用已部署的Web应用程序启动服务器之前检查此文件是否存在.

The struts.xml configuration file should be in the source folder, such as src or resources. When you build the application the compiled output directed to WEB-INF/classes. You can check this file exists before you deploy or start a server with already deployed web application.

仅供参考,约定插件不会替换XWork配置,但会对其进行扩展以使其覆盖. struts.xml出于相同的目的使用,但使用不同的配置提供程序.因此,使用约定插件配置拦截器可确保使用包含自定义拦截器的正确父包.

FYI, the convention plugin doesn't replace the XWork configuration, but extend it with possibility to override. The struts.xml is used by the same purpose, but using different configuration provider. So, configuring interceptors using convention plugin make sure you use the right parent package that contains your custom interceptor.

这篇关于在struts.xml中使用约定插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆