Results 1 to 9 of 9
Thread: spring baby steps
- 02-12-2017, 08:32 PM #1
Senior Member
- Join Date
- Sep 2016
- Posts
- 108
- Rep Power
- 0
spring baby steps
Hello all, So I have been adventuring with Spring Boot to try and learn. So far I have a boot application that can add to or show all elements in a MySQL database. i either put localhost/sql/all to show them all or localhost/sql/add?ID=1&name=jason&brief=whatever&description=wha tever&rank=5 to add a new entry.
What I want to do now is add web pages where I can have a form instead of typing it all in the address bar. So do I use jsp or html or how should I approach this? I use gradle to build not maven I dunno if that matters in terms of approach or not. Any good tutorials or links to ideas would be appreciated, thanks.
- 02-13-2017, 12:17 AM #2
Senior Member
- Join Date
- Sep 2016
- Posts
- 108
- Rep Power
- 0
Re: spring baby steps
also I am having a problem with this file. when I click submit it loads a page that says:
Java Code:Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Sun Feb 12 16:15:51 CST 2017 There was an unexpected error (type=Method Not Allowed, status=405). Request method 'POST' not supported
here is the code. If you need the related files to know whats wrong let me know ill post it.
Java Code:package jasonWebpage; import javax.validation.Valid; import org.springframework.stereotype.*; import org.springframework.validation.*; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.config.annotation.*; @Controller public class PersonController extends WebMvcConfigurerAdapter{ @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/results").setViewName("results"); } @GetMapping("/form") public String showForm(jasonWebpage.PersonForm personForm) { return "form"; } @PostMapping("/form") public String checkPersonInfo(@Valid jasonWebpage.PersonForm personForm, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return "form"; } String go = "/result.html"; return "redirect:/results"; } }
- 02-13-2017, 12:03 PM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Re: spring baby steps
These days the site would be HTML/Javascript, rather than JSP. Or at least mostly that.
So the Javascript on a page makes requests for whatever data the page is expected to show.
There are frameworks for doing this. AngularJS is the current workhorse, but you might want to look at newer ones, like React.
So essentially your site consists of Javascript that makes RESTful calls to your services and uses the results to construct the page.
As for your second part. is there a stack trace on the server?Please do not ask for code as refusal often offends.
** This space for rent **
- 02-13-2017, 04:34 PM #4
Senior Member
- Join Date
- Sep 2016
- Posts
- 108
- Rep Power
- 0
Re: spring baby steps
ah thanks for the explaination, that makes sense. There are some guides on the spring web site for AngularJS. I will check those out.
and this is what the error says
Java Code:Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Mon Feb 13 08:26:06 CST 2017 There was an unexpected error (type=Method Not Allowed, status=405). Request method 'POST' not supported
I combined like 3 examples into one so in two of the examples it told me to have a index in static folder. So I did that and built upon that making some pages I can click back and forth between. Then one of the examples had all the html files in the templates folder so I put those ones there and these are the ones that I have problems getting.
- 02-13-2017, 05:11 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Re: spring baby steps
And there's nothing in the server logs?
What's the URL you are hitting?
Stick some debugging in the POST method to see if it even gets there (doesn't look like it to me).Please do not ask for code as refusal often offends.
** This space for rent **
- 02-14-2017, 06:43 AM #6
Senior Member
- Join Date
- Sep 2016
- Posts
- 108
- Rep Power
- 0
Re: spring baby steps
WARN 7772 --- [nio-8080-exec-8] o.s.web.servlet.PageNotFound : Request method 'POST' not supported
Not finding the page. I am going to look into more examples and see if i can't figure it out.
- 02-14-2017, 10:52 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Re: spring baby steps
I'd still put some debugging in there.
Java Code:log.debug("Request to checkPersonInfo");
Please do not ask for code as refusal often offends.
** This space for rent **
- 02-16-2017, 05:34 AM #8
Senior Member
- Join Date
- Sep 2016
- Posts
- 108
- Rep Power
- 0
Re: spring baby steps
okay I shall try that. I haven't messed with the log much yet.
- 02-16-2017, 10:27 AM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Similar Threads
-
Predicting the gender of a baby HELP PLEASE
By finn_the_human in forum New To JavaReplies: 4Last Post: 09-10-2014, 11:38 AM
Bookmarks