Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

Some questions from a newbie...

$
0
0
Hello,

iam a pupil from Germany. At First - sorry for my bad language :) I hope anyone can help me to understand the whole Spring thing....

I can not display the data of the model on my jsp page... :(

There is no error message. The page.jsp won't show the last name. It's only blank after "Your last name is".
I tried many different things an the jsp page. mode.Lastname, user.Lastname, model.user.Lastname.... nothing works....

please help :D

using: NetBeans 7.3, Spring 3.1.1, Glasfish Server 3.1.2

Controller:

Code:

package de.tafelstellwerk.test;

import de.tafelstellwerk.test.Cuser;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;


/**
 *
 * @author Eyore
 */

@Controller
public class Test {
   
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public ModelAndView Profil(Model model) {
   
      Cuser user = new Cuser();
      user.setFirstname("John");
      user.setLastname("Doe");
      model.addAttribute("User", user);
      return new ModelAndView("page", "form", model);

    }}

JSP:
HTML Code:

<%--
    Document  : page
    Created on : 22.08.2013, 16:58:30
    Author    : Eyore
--%>

<%@ page contentType="text/html" pageEncoding="UTF-8" language="java" buffer="64kb"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form:form commandName="form">
           
                    Your last name is<h1>${model.Lastname}</h1>
           
        </form:form>
    </body>
</html>


Class user:
Code:

package de.tafelstellwerk.test;

/**
 *
 * @author Eyore
 */
public class Cuser {
   
    String Lastname;
    String Firstname;

    public String getLastname() {
        return Lastname;
    }

    public void setLastname(String Lastname) {
        this.Lastname = Lastname;
    }

    public String getFirstname() {
        return Firstname;
    }

    public void setFirstname(String Firstname) {
        this.Firstname = Firstname;
    }
 
}


Viewing all articles
Browse latest Browse all 297

Trending Articles