spring-mvc

spring MVC form action not adding project name

谁都会走 提交于 2020-01-06 13:53:58
问题 I am working on sample spring MVC applicaiton. created My issue is in form i mapped action to some method , but after submitting form it removes the project name and request is just becomes like: localhost:8080/addUser rather than localhost:8080/myproject/addUser Required details : web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns

Error creating bean with name 'templateResolver'

为君一笑 提交于 2020-01-06 12:42:21
问题 I am new to Thymeleaf . I am integrating Thymeleaf to Spring3. Can anybody tell me what do I need to do to solve this Error? org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'templateResolver' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.thymeleaf.templateresolver.ServletContextTemplateResolver org.springframework.beans

Sending HTML data through AJAX using Spring MVC

本秂侑毒 提交于 2020-01-06 12:37:14
问题 I have an AJAX call which is processed and a jsp page is returned by Spring. @RequestMapping(value = "/getData.do") public String getData() { // ... return "data"; } and I am returning data.jsp . The AJAX call looks like this: $.ajax({ type : 'GET', url : "getData.do", error : function() { alert('failure'); }, success : function(result) { alert("Success"); } }); I have servlet mapping in web.xml for .do files <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>*.do</url-pattern

How to use multiple places in Spring viewresolver?

*爱你&永不变心* 提交于 2020-01-06 10:54:05
问题 this is how I define the loaction of my jsp files: <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> But I have too many JSP files in one folder at the moment...I changed my directiory structure to this: /WEB-INF/jsp/city/*.jsp /WEB-INF/jsp/weather/*.jsp How must

How to use multiple places in Spring viewresolver?

﹥>﹥吖頭↗ 提交于 2020-01-06 10:52:49
问题 this is how I define the loaction of my jsp files: <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> But I have too many JSP files in one folder at the moment...I changed my directiory structure to this: /WEB-INF/jsp/city/*.jsp /WEB-INF/jsp/weather/*.jsp How must

DTO returns null when called from a Rest client using spring boot

落爺英雄遲暮 提交于 2020-01-06 10:05:54
问题 This is making a spring boot project to maintain the MVC architecture and as well being RestFul. There is a project that is fully working properly using the MVC architecture, I'll like to make it work as well by being called from a Rest client. Posting from the Thymeleaf UI works fine, however, when I try to post from a Rest client all the DTO properties are null. I don't know why. How do I make the posting from the client get all the properties posted? UserDto @PasswordMatches public class

DTO returns null when called from a Rest client using spring boot

狂风中的少年 提交于 2020-01-06 10:05:12
问题 This is making a spring boot project to maintain the MVC architecture and as well being RestFul. There is a project that is fully working properly using the MVC architecture, I'll like to make it work as well by being called from a Rest client. Posting from the Thymeleaf UI works fine, however, when I try to post from a Rest client all the DTO properties are null. I don't know why. How do I make the posting from the client get all the properties posted? UserDto @PasswordMatches public class

Spring: Register Handler Method dependening on Order annotation

坚强是说给别人听的谎言 提交于 2020-01-06 09:56:42
问题 I have two Controllers: @Controller @Order(Ordered.LOWEST_PRECEDENCE) public class BaseController { @RequestMapping("/hello.html") public String hello(ModelMap model) { model.addAttribute("hello", "world"); return "hello"; } } @Controller public class ProjectSpecificController { @Autowired private BaseController baseController; @Override @RequestMapping("/hello.html") public String hello(ModelMap model) { model.addAttribute("project", "name"); return baseController.hello(model); } } As Spring

Spring Menu Configuration

天涯浪子 提交于 2020-01-06 09:52:05
问题 I am working with the spring MVC 4 and configuring the menu in my home page which is to be shown based on role which i have define. So in my menu-config.xml i am defining as <Menu name="Company" title="menu.companyTitle" page="/xxx/yyy/zzzz"> <Item name="NewCompanyRequest" roles="ROLE_ADMIN,ROLE_USER" title="menu.NewCompanyRequest" page="/admin/companyRequestList" /> <Item name="editCompanies" roles="ROLE_ADMIN" title="menu.editCompanies" page="/xx/yyy/ccc" /> </menu> <Menu name="Exchaged"

Converting & validating CSV file upload in Spring MVC

♀尐吖头ヾ 提交于 2020-01-06 08:21:19
问题 I have a Customer entity that contains a list of Sites, as follows: public class Customer { @Id @GeneratedValue private int id; @NotNull private String name; @NotNull @AccountNumber private String accountNumber; @Valid @OneToMany(mappedBy="customer") private List<Site> sites } public class Site { @Id @GeneratedValue private int id; @NotNull private String addressLine1; private String addressLine2; @NotNull private String town; @PostCode private String postCode; @ManyToOne @JoinColumn(name=