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 :)
Related
I try to make a Web service using JAVA and SOAP, but every time I try to run the application, I get the following error: No endpoint mapping found for [SaajSoapMessage {http://api.com}getCountryRequest].
I have been attempting to expose listed endpoints like mentioned on Stack Overflow, but has no effect. Furthermore, I also attempted to add the following code to the application.properties file:
spring.webservices.expose-all-endpoints=true
But it doesn't work. Then I set out to add another code to the application.properties file:
management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=env,beans
But that didn't work either. I have tried many ways to solve this problem for a long time, but I can't find a solution. I will be genuinely grateful if you can help me. Thank you in advance.
Note: To re-create the issue, here is my repo
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:
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
I have a spring boot application where I serve some static jsp pages stored in directory src/main/webapp which includes some javascript references stored under directory "src/main/resources/static". When I do the requestmapping for "/somepath" then it successfully returns view that has javascript references in static resources folder such as "src/main/resources/static/lib/script.js"
But the problem that I'm facing right now is when I do the #requestmapping to "/sompath/xyz" then I get HTTP 404 error. When I inspected the page source then I found out that the page was searching for static folder in this path "/somepath/lib/script.js" that is "/somepath" is getting prefixed to the default resources location. Is there any way that I could map these URIs such that no matter how many "/path/" are there, it will look for resources under the "/static/" folder only and not like "/static/path"
Any help is appreciated. I apologise for my problem structure as I'm a beginner and I'm still learning to put all these things in better perspective. Thanks in advance.
I have same problem I found the way but its half solution.
first
use RequestMapping path depth just one like 'spring'
It is work well every situation.
second
use RequestMapping path depth tow like 'spring/xyz' and <link src="../some.css"/>
last
use depth 3 'spring/xyz/123' and <link src="../../some.css"/>
This all is messed up but it is working.
So I open the question on stack overflow again here please anyone come and check this and leave some idea thanks~!
I am using Tomahawk's fileupload component <t:inputfileupload> for uploading files. I've set enctype of form as
enctype="multipart/form-data"
and I used <h:commandButton> to submit the form.
But the UploadedFile property in the bean is null. What am I doing wrong and how can I fix it?
Ensure that you've configured the ExtensionsFilter as per their documentation. It's the one responsible for processing multipart/form-data requests and setting the appropriate parts as bean properties.
See also:
Uploading files with JSF
Ensure that you are not using nested forms. Because upload component dont run in nested forms.
It will throw null pointer exception.
I got this issue when I had started on the basis of faces extensions -> the stuff where you put
<%# taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
and use myfaces-extensions-1.0.9.jar.
There is a tutorial on that approach at onjava.com but the tutorial is from year 2005 and does not work with the current jsf1.2 versions. Being fighting with that very old solution tutorial found with google I realized it's worth of checking always that you're using uptodate tutorials also not just uptodate jar-versions.
I wanted to give this solution to those who also have started this thing from upside down.