使用 Spring.net 进行 xVal 验证
我开始使用 xVal 作为 ASP.Net MVC 应用程序的验证框架。 我使用 Spring.Net IoC 容器将应用程序保存在一起。
我已按照 Steve Sanderson 博客上的说明进行操作,以使服务器端验证正常工作。 但是,当我尝试让客户端工作时,出现以下运行时异常:
Spring.Objects.Factory.NoSuchObjectDefinitionException was unhandled by user code
Message="No object named 'Scripts' is generated : Cannot findDefinition for object [Scripts]"
我认为这是因为 Site.Masterpage 有以下内容其中的代码:
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/jquery-1.2.6.js")%>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/jquery.validate.js")%>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/xVal.jquery.validate.js")%>"></script>
正在尝试使用 Spring 解析 ~/Scripts/ 。
我如何让 Spring 来处理这个问题(即配置 XML 中的内容),或者我在 Site.Master 中更改什么,这样就不会发生这种情况?
I have started to play with xVal as my validation framework for an ASP.Net MVC application. I use the Spring.Net IoC container to hold the app together.
I have followed the instructions on Steve Sanderson's blog to get server side validation working fine. But when I try to get client side working, I get the following runtime exception:
Spring.Objects.Factory.NoSuchObjectDefinitionException was unhandled by user code
Message="No object named 'Scripts' is defined : Cannot find definition for object [Scripts]"
I presume this is because the Site.Masterpage has the following code in it:
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/jquery-1.2.6.js")%>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/jquery.validate.js")%>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/xVal.jquery.validate.js")%>"></script>
Which is trying to resolve ~/Scripts/ using Spring.
How do I get either Spring to cope with this (i.e. what goes into the config XML), or what do I change in Site.Master so this does not happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哦,在史蒂夫的帮助下我找到了答案。 不要盲目地从网上复制和粘贴示例,我的脚本文件夹中有 jquery-1.3.2.js,而不是 1.2.6。 通过将 Site.Master 文件中的引用更改为正确的版本号,一切就开始工作了。
Opps, with Steve's help I found the answer. Don't blindly copy and paste samples from the web, I have jquery-1.3.2.js in my scripts folder, not 1.2.6. By changing the reference in the Site.Master file to be the correct version number, it all started working.