Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8350097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:12:26+00:00 2026-06-09T08:12:26+00:00

I have a model object in my controller. let’s say Class person{ Date birthDay;

  • 0

I have a model object in my controller.

let’s say

Class person{
    Date birthDay;
}

when it is show in the form:input, if user input “aaaaa”, of course it will fail and I just direct user to the same page and show them the error by putting the person to model again. but is there a way to keep the user wrong input at the input field?

<form:input path="birthday"/>

will just show empty because the binding fail. do I have to use a DTO object and make everything as string so wrong input can still be shown?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:12:28+00:00Added an answer on June 9, 2026 at 8:12 am

    I cannot replicate your situation. Can you provide more code? Mine exapme shows wrong input:

    public class Person {
    
    private Date birthDay;
    
    public void setBirthDay(Date birthDay) {
        this.birthDay = birthDay;
    }
    
    public Date getBirthDay() {
        return birthDay;
    }
    }
    

    Controller:

    @Controller
    @RequestMapping("/person")
    public class PersonController {
    
    
    
    @RequestMapping(value ="/edit", method=RequestMethod.GET)
    public String edit(Person person, BindingResult result){
    
        return "person/edit";       
    }
    
    @RequestMapping(value ="/edit", method=RequestMethod.POST)
    public String submit(Person person, BindingResult result){
        if(result.hasErrors()){
            return "person/edit";   
        } else {
            return "redirect:person/edit.ss";
        }
    }
    

    Jsp:

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 
    <form:form method="POST" modelAttribute="person">
    Birth day: <form:input path="birthDay" /><form:errors path="birthDay" />
    <br />
    <input type="submit" value="Submit" />
    </form:form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a model object 'Person' defined, which has a field called 'Name'.
Let's say you've got a domain model class for a Song. Song's have a
Let's say you have this Model: //model public class Stuff { public string Name
I have a data model object User . My app also has some other
Let's say I have: object A, B, C each with corresponding models, views, and
Both OOD (Object-Oriented-Design) and MVC (Model-View-Controller) architectures have become staples of modern software design.
Let's say I have a handler in a Spring MVC controller: @RequestMapping public String
Let's say I have on my controller: @parts = Part.all and on the view
Let me have two very basic objects like: public class View { public View(Controller
Given I have a Model object like ... public class MyModel { public int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.