I am trying to set up a basic MVC controller project. I have created a servlet and
couple of jsp pages. I can deploy the project and access the jsp pages.
The problem starts when I try to use the LoginController. The error I am getting is 404 error. Please help.
I have attached a screenshot of my codes and project structure. I gut instinct is the dispatcher servlet is not working the way it suppose to (just a guess).
I have googled and fiddled with the code for the past 5 hours to no avail. This is my first time asking question on S/O enter image description hereso I apologies If this is not in the correct format.
localhost:8084/springmvcDemo/login
change to
localhost:8084/springmvcDemo/spring-mvc/login
This link will help you
Related
I get blank screen when execute http://localhost:9001/forms/frmservlet.
I am using java 1.8.0_321, WebLogic 12 y forms 12.
I have lost several days trying to fix.
Any recomendation?
A blank page is a 'successful' response from the code running behind /forms/frmservlet.
There are a few things you can check:
Which code is sending the blank page? Is it your code or is your webapp on a different path? Is your servlet mapped correctly?
Look at the HTML source in the browser to understand better the blank page
Check Weblogic's logfiles to see if something unusal is in there
All this may sound pretty generic but you did not give more details either.
I am trying in Springboot mvc for some time and have a problem:
my app auto generates List of Commentaries. I'd like to show them one by one on website.
I know there is solution in js but dont know yet a lot on js. trying first in java/spring.
I found js solutions on stackoverflow but hard to me to implement them to my app - idk how/where to put js script in template nor js function in controller/service.
guys, could you guide me with the simplest solution?
I am fairly new to using JSP but all I want to do at the minute is call a simple method from a JSP scriptlet. There are questions similar to this on this forum already, but any solution to those problems always seemed to be related to a simple typo, however as far as I can see, there is no typo in my code but I could be wrong.
Here is my JSP file (ShowBookings.jsp)-
This is the Controller class that I am attempting to call.
This is the HTTP Status 500 – Internal Server Error I get when I try to run the web page.
I used images instead of code snippets to give a better idea of exactly what I am seeing. When I type in "controller.;" in the jsp file, the methods appear in the intellisense including the sayHello() method, so it does seem to be visible from the jsp file but it is still throwing an error. Any help or advice would be greatly appreciated.
I have a problem using Spring MVC. Please keep in mind that I read about 15 topics asking the same question, and none of them gave me the answer. I'm kind of lost right now.
First of all, my code was smoothly working before I modified few functions in different layers. Then, when I try to log my page, I get a warn which is :
WARN (org.springframework.web.servlet.PageNotFound) - No mapping found for HTTP request with URI [/bo/newsletter/accueil] in DispatcherServlet with name 'dispatcher'
All subjects I read were talking about modifying the web.xml file, which I tried. Without success.
Simply have my
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/newsletter/*</url-pattern>
</servlet-mapping>
, which, as I said, worked properly few modifications ago.
So I tried to comment all my code, except the function that simply displays the main view. So I commented Controller, Service, DAO, SQLMapper. Still doesn't work.
The strange thing is that it works as a charm if I change my url path "[...]/newsletter/home" (which is my desired url) to "[...]/actualites/newsletter/home" ("actualites" being a path working, "actualites/home" for example).
Found the solution few days ago.
I misunderstood how annotations were supposed to work. My NewsletterController being annoted by #Controller, I placed #GetMapping, #DeleteMapping, etc. instead of #RequestMapping and then placing the type of request.
Thanks for helping anyway ! Strange error that popped tho, hope the solution'll help some :)
I have a new project and it's my first time using spring MVC and Thymeleaf.
The error message that I'm getting seems obvious:
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers
I have googled a lot and saw many people with similar issues. However, none of the solutions helped me find out why my setup does not work.
Instead of classpath:/templates I have also tried variations like templates and /templates
some questions:
What is the "basedir" from which the relative path is being looked for?
Is it possible to run spring in debug to see how these kind of configurations are set? i.e. call when I call localhost:8080 and there's a breakpoint somewhere: would it be possible to see how the file index.html is being looked for?
edit On line 23 in the document on the right (BetterCommuteApplication.java) you can see that Intellij is able to resolve the reference to my template file.
This screenshot shows my configuration and I think it should suffice as enough information to get the answer.
Thank you for your time! :-)
ugh, I tried to combine Spring boot with thymeleaf manually here.
(I'm used to developing back-ends ^^")
This doesn't make much sense as initialising spring MVC does this right out of the box.
The solution was to init this as springMVC, use #Controller instead of #Restcontroller because I want the class to be handled as MVC class... and the return could be as simple as return 'index' (because my html file in the default location is called index.html)
basically I would have known, if I'd simply followed the tutorial on SpringMVC... but hey, why would anyone RTFM? :-)
so it looks like this: