java - JSP output plain text in Web Browser -


i using eclipse, spring mvc, maven , tomcat. index.jsp displays show below in web browser. not rendering properly.

any idea wrong?

index.jsp <%@ page language="java" contenttype="text/html; charset=iso-8859-1"     pageencoding="iso-8859-1"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>insert title here</title> </head> <body>     <h1>index</h1> </body> </html>  @controller public class hellocontroller {      @requestmapping("/greeting")     public string sayhello() {         system.out.println("greeting");         return "hello";     }      @requestmapping("/")     public string index() {         system.out.println("index page");         return "index";     } } 

a controller has , post requestmethod.however @ quick glance need change @requestmapping("/greeting") @requestmapping(value = "/greeting") starters. default jsp file should in /src/main/webapp/web-inf/views (spring mvc starter project)

when return string - spring mvc jsp .jsp. in example want have greeting.jsp

@controller public class greetingcontroller {   /**   *   */  @requestmapping(value = "/greeting", method = requestmethod.get) public string handlerequest() { // used when url   return "greeting";  }   /**   * post   */  @requestmapping(value = "/greeting", method = requestmethod.post)  public string processsubmit(){    // used when post url   //todo here , put right in page    return "greeting";  } } 

go ahead , comment if have other questions. check account other example neither bindingresult nor plain target object bean name available request attr

hope helps. luck!

just note spring has more requestmethod's , post used , easiest understand.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -