简体   繁体   English

如何在Struts2中将参数化方法用作操作方法?

[英]How to use a parameterised method as an action method in struts2?

I have this method as an action method in struts2 我将此方法作为struts2中的操作方法

public String validateUser(User u) 公共字符串validateUser(用户u)

What entry should I add in struts.xml file ? 我应该在struts.xml文件中添加什么条目?

You can't. 你不能 Even though struts2 makes our lives much easier giving us the MVC approach to web programming, HTML will be always be HTML and the only things you can pass as parameters on HTML are good 'ol strings. 尽管struts2为我们提供了MVC进行Web编程的方法,使我们的工作变得更加轻松,但HTML始终将是HTML,并且可以作为HTML参数传递的唯一东西就是好的'ol字符串。

You can put it on the Session though. 您可以将其放在会话中。 Yet remember sessions are fragile and short-lived 但是请记住,会议是脆弱且短暂的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM