Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Adding empty line to modelattribute

  1. #1
    Junior Member
    Join Date
    Jan 2019
    Location
    Belgium
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Question Adding empty line to modelattribute

    Hi Guys

    I'm new to this forum, so don't shoot me if i posted in the wrong place.
    I have a springBoot app that uses a modelAttribute to return a message when an error occurs while login in.
    Everything is working fine, but something bugs me. The error message is concatenated together.
    I wan't to add some line separators to the errormessage.
    I've tried System.lineSeparator(), \n an <break> but nothing seems to work.
    I use a stringBuilder to build the message and then call the to string message when adding the attribute to the model.
    Any tips?

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Adding empty line to modelattribute

    Is this a standard java question or is the problem caused by the framework?
    Can you print the String that is being created to see if the new-line character is honored on the console.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jan 2019
    Location
    Belgium
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Adding empty line to modelattribute

    Good question! I checked and it is...
    this is on the console:
    Username already chosen!

    This e-mail is already registered.
    Did you forget your password?

    This is on the actual page:
    Username already chosen! This e-mail is already registered. Did you forget your password?
    Last edited by ufotje; January 15th, 2019 at 07:22 AM. Reason: added the message

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Adding empty line to modelattribute

    So is there any documentation that says that new-line characters will be removed?

    Does the software that displays the message support the new-line character you are using.
    For example on Windows, Notepad needs \r\n for a new-line.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Jan 2019
    Location
    Belgium
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Adding empty line to modelattribute

    I use intelij as idea, so it supports new-line and it's actually being displayed in firefox, since it's a webpage and they shouldn't have any issues with it...
    Just to be shure I tried "\r" and "\r\n" didn't work eather

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Adding empty line to modelattribute

    If it is html text, did you try the <br> tag?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Jan 2019
    Location
    Belgium
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Adding empty line to modelattribute

    I did try <br> but it's not html text it's a StringAttribute in the model

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Adding empty line to modelattribute

    displayed in firefox
    I guess that was confusing.

    I don't know the framework and can't suggest anything else.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Re: Reading a file line by line using the Scanner class
    By rajaveluswamy in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 8th, 2013, 03:38 AM
  2. Replies: 10
    Last Post: September 16th, 2011, 07:49 PM
  3. Replies: 4
    Last Post: May 15th, 2011, 06:03 AM
  4. Reading a file line by line using the Scanner class
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: April 17th, 2009, 07:34 AM
  5. How to Read a file line by line using BufferedReader?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 06:32 AM

Tags for this Thread