English 中文(简体)
如何使用春 to的 j子
原标题:How to use jQuery datepicker with Spring

I am trying to use a datepicker calender with Spring MVC submission form.I am able to use the date calender in the form,but when i submitting the page i want to see the values in the controller rest of the values are coming to the servlet but the date is not coming .i a posting the code below This is the form in the view page

 <div align="center">
    <form:form action="forms/registerResult" method="post"
        commandName="userForm">
        <table border="0">
            <tr>
                <td colspan="2" align="center"><h2>Spring MVC Form Demo -
                        Registration</h2></td>
            </tr>
            <tr>
                <td>User Name:</td>
                <td><form:input path="username" /></td>
            </tr>
            <tr>
                <td>Password:</td>
                <td><form:password path="password" /></td>
            </tr>
            <tr>
                <td>E-mail:</td>
                <td><form:input path="email" /></td>
            </tr>
            <tr>
                <td>Birthday (mm/dd/yyyy):</td>
                <td><form:input path="birthDate" /></td>
            </tr>
            <tr>
                <td>Profession:</td>
                <td><form:select path="profession" items="${professionList}" /></td>
            </tr>
            <tr>
                <td>Date:</td>
                <td><form:input path="date" id="datepicker" /></td>
                <script>
                    $(function() {
                        $("#datepicker").datepicker();
                    });
                </script>

            </tr>
            <tr>
                <td>Skills:</td>
                <td><form:select path="javaSkills" items="${javaSkillsList}"
                        multiple="true" /></td>
            </tr>
            <tr>
                <td colspan="2" align="center"><input type="submit"
                    value="Register" /></td>
            </tr>
            <tr>
                <td>Sex :</td>
                <td><form:radiobutton path="sex" value="M" />Male <form:radiobutton
                        path="sex" value="F" />Female</td>

            </tr>
        </table>
    </form:form>
</div>

这是我的保护手册。

 public class AppContoller {

@RequestMapping(value="/register",method=RequestMethod.GET)
public String viewRegistration(Map<String,Object>model){
    User userForm=new User();

    model.put("userForm", userForm);

    List<String> professionList=new ArrayList<String>();
    professionList.add("Developer");
    professionList.add("Designer");
    professionList.add("IT Manager");
    model.put("professionList",professionList);

    List<String> javaSkillsList=new ArrayList<String>();
    javaSkillsList.add("JAVA");
    javaSkillsList.add("C#");
    javaSkillsList.add("C++");
    model.put("javaSkillsList",javaSkillsList);



    return "Registration";
}

@RequestMapping(value="/registerResult",method=RequestMethod.POST)
public String processRegistration(@ModelAttribute("userForm")User user,Map<String,Object> model){

    System.out.println("username:"+user.getUsername());
    System.out.println("password:"+user.getPassword());
    System.out.println("email:"+user.getEmail());
    System.out.println("birth date:"+user.getBirthDate());
    System.out.println("profession:"+user.getProfession());
    System.out.println("skills:"+user.getJavaSkills());
    System.out.println("date:"+user.getDate());
    return "RegistrationSuccess";


}

系统.out.println (“date:”+user.getDate ()); is not come to the console.please any person help.

问题回答

When you say Spring, I guess you are mainly talking about the Spring MVC part. That s mainly a backend stuff, jquery plugin is frontend, so it seems they don t even need to integrate with each other.

春天控制器可以简单地为你们的html回旋,你可以在那里穿透任何观点。

如果你想生动地创造出html,那么你需要使用一些技术,如共同财产制或图伊里叶,这两种技术都使你能够轻松地将焦炭法植根。

Is the jquery.js file able to be loaded? check that using console of chrome. You might regist resource path as like this

<resources mapping="/js/**" location="/js/" />

检查如下:

  1. Return type of the user.getDate() function, it might create problem if it is other than string.
  2. 如果包含所有必要的参考资料。

    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
    

以下各条对包括所有法典在内的全部细节作了解释。

jquery date picker in spring mvc





相关问题
array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签