Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Shane Conroy
Courses Plus Student 11,125 Points500 Server Error: INFO spark.http.matching.MatcherFilter - The requested route [/undefined] has not been mapped in Spark
I've followed the video to a t as far as I can tell, but I'm still getting a 500 when I submit the form. Server log from IntelliJ says the following (twice after each submission):
INFO spark.http.matching.MatcherFilter - The requested route [/undefined] has not been mapped in Spark
Looks like Spark isn't getting the correct route name for some reason?
Here's my Main file:
package com.teamtreehouse.courses;
import spark.ModelAndView;
import spark.template.handlebars.HandlebarsTemplateEngine;
import java.util.HashMap;
import java.util.Map;
import static spark.Spark.*;
/**
* Created by pokechopp on 9/17/16.
*/
public class Main {
public static void main(String[] args) {
port(9999);
get("/", (req, res) -> {
return new ModelAndView(null, "index.hbs");
}, new HandlebarsTemplateEngine());
post("/sign-in", (req, res) -> {
Map<String, String> model = new HashMap<>();
model.put("username", req.queryParams("username"));
return new ModelAndView(model, "sign-in.hbs");
}, new HandlebarsTemplateEngine());
}
}
And the index.hbs file:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Hello Students!</title>
</head>
<body>
<h1>Welcome Students!</h1>
<form action="/sign-in" method="post">
<input type="text" placeholder="What's your name?" name="username">
<button>Sign In</button>
</form>
</body>
</html>
aaaaaand for good measure, the sign-in.hbs file (though it seems like the request isn't even making it here in the first place):
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Signed In</title>
</head>
<body>
<p>Welcome {{username}}}</p>
</body>
</html>
Shane Conroy
Courses Plus Student 11,125 PointsShane Conroy
Courses Plus Student 11,125 PointsNever mind. It was the extra bracket in the sign-in.hbs file.