How to check if my value is null or empty?

我的梦境 提交于 2019-12-02 07:12:48
  • 1
    surname == null || surname == ''. – Aleksandr M Jun 20 '14 at 10:51
  • very fast answer! Thank you. It works. I think it is time for me to dig those concepts of using # or { or nothing because I am lost. – EColi Jun 20 '14 at 10:59
2

Its better using validation.So that these validation codes will be removed from view layer(JSP). You can inherit method validate() to your action class by extending ActionSupport. Add your validation codes here.If validation catch any error it will show above the jsp page textbox.

  • Of course!! That is how I should do it. I read about it and then totally forgot about it. Thank you for reminding me the right way to do it. – EColi Jun 23 '14 at 17:54
  • You are welcome :) – afsal parangooz Jun 24 '14 at 4:55
1

So finally I wrote the code:

<s:if test="%{ (surname!=null) && (!surname.isEmpty()) }">

and inverted the content of the if and the else, as the test is the opposite.

No need for # or {.... because surname is in the value stack so it is directly accessible.

    0

    the “debug” tag is a very useful debugging tag to output the content of the “Value Stack” and also the “Stack Context” details in the web page

    for more reference u may see this link Debugging Struts <s:debug /> in body

    • I have tried ton insert this <s:debug /> but it created some errors so I left it behind, perhaps i should give it another try because it should be very useful – EColi Jun 20 '14 at 11:03

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

    Not the answer you're looking for? Browse other questions tagged or ask your own question.

    标签
    易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
    该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!