Posts

Showing posts with the label spring-mvc

Spring can not load CSS

Spring can not load CSS Hello I have a little problem, when i'm starting my Spring boot web app, when i'm going to my localhost it cant load CSS. I figured out that it's happening after adding "@ComponentScan" into Main class. So i tried to remove it and then my whole controllers couldnt load ... Meybe someone know solution to this problem. I've tried for about 3 days to do it and nothing helped. I'm putting a code below. meybe someone could figre it out for me. MAIN.class @SpringBootApplication @EntityScan({"com.estomed.Model"}) @EnableJpaRepositories({"com.estomed.Repository"}) @ComponentScan(basePackages = {"com.estomed"}, useDefaultFilters = true) public class SynchronizesiteApplication { public static void main(String args) { SpringApplication.run(SynchronizesiteApplication.class, args); } } WebConfig.class @Configuration public class WebConfig implements WebMvcConfigurer { @Override public void addResourc...

Cannot find class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactory] for bean with name 'sessionFactory'

Cannot find class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactory] for bean with name 'sessionFactory' i created a project in spring using maven dependencies but i am getting the above mentioned error. i changed the version of hibernate dependency but stil it does nt get resolved here is the code: pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.shr</groupId> <artifactId>apps</artifactId> <name>SpringJdbcProject</name> <packaging>war</packaging> <version>1.0.0-BUILD-SNAPSHOT</version> <properties> <java-version>1.6</java-version> <org.springframework-...

Static resource mapping in Spring3

Static resource mapping in Spring3 My project is implemented in Spring3 and configuration is almost xml. Configuration of static resource mapping is like below: <mvc:resources mapping="/a/**" location="file:/data/a/"/> There is no problem when accessing /a/xxx.jpg but 404 Error is occurred when accessing subdirectory like /a/b/yyy.jpg. There is no problem about access authority of filesystem. How can I solve this problem? Additional configuration is needed? (Add) Project directory is fine, but filesystem directory does not work 1 Answer 1 Use something like below : <mvc:resources location="/" mapping="/resources/**"/> You can specify classpath also to location any particular folder like below. <mvc:resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**"/> Project direc...

request.getRequestURI always returns “/error”

request.getRequestURI always returns “/error” In a webapp I'm building using Spring Boot & MVC and am trying to deny access to for all URL's except /signin for users that are not logged in. To achieve this I've setup an implementation of HandlerInterceptor where the preHandler should route all non-valid requests to the /signin page. The setup: LoginViewController package com.controller; import com.model.UserDao; import com.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.SessionAttributes; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @Controller @RequestMapping(value = "/signin") @SessionAttributes("username...