spring-mvc

How to pass value or param from jsp to Spring controller?

女生的网名这么多〃 提交于 2020-01-25 20:55:14
问题 I'm trying access some value from my jsp file in Spring controller. All examples that I've found was with <input> or <form> code, but I want to pass "clear" value (just String), for example <c:set var="name" value="Ololo"/> or smth like this and print it in Conroller. 回答1: You can't. Data can flow only in one direction, from controller to view (jsp). If you have to send information back to the controller then you should make http request. That's the reason you only see <form> and <input> in

Send complex json object to Spring MVC controller

淺唱寂寞╮ 提交于 2020-01-25 20:51:32
问题 I am trying to send a complex object to ajax controller for spring mvc search engine, with 3 variables: the current page, items per page and the search parameters. The problem is that with the declaration of the controller method does not take me the params variable as a Map. As I can send the structure to collect on the controller 3 variables separately? Error: Required Map parameter 'params' is not present var dataToSend = { 'page': 1, 'itemsPerPage': 10, 'params': { 'codItem': "10",

Send complex json object to Spring MVC controller

孤者浪人 提交于 2020-01-25 20:51:02
问题 I am trying to send a complex object to ajax controller for spring mvc search engine, with 3 variables: the current page, items per page and the search parameters. The problem is that with the declaration of the controller method does not take me the params variable as a Map. As I can send the structure to collect on the controller 3 variables separately? Error: Required Map parameter 'params' is not present var dataToSend = { 'page': 1, 'itemsPerPage': 10, 'params': { 'codItem': "10",

How to call Spring MVC from Javascript?

亡梦爱人 提交于 2020-01-25 20:22:46
问题 How do you instantiate a custom object from a request param? (I have tried both @ModelAttribute and @RequestParam) @RequestMapping(method = RequestMethod.POST) public String newPerson(@ModelAttribute(value = "personModel") Person person, BindingResult result) { // Person has just firstname and lastname fields } I try to call this with jQuery using the following code: var PersonText = '["firstname":"John", "lastname":"Someone"]'; $.ajax({ type : 'POST', url : "/addnewperson.do", data : {

DWR 3.0.2 Spring 5.1.7 Upgrade 'You must include DWR engine before including this file'

梦想与她 提交于 2020-01-25 10:44:28
问题 Environment Websphere 8.5.5.11 JDK 1.8 DWR SpringMVC Oracle DBMS We recently upgraded our project, and make updates from spring.jar, spring-web.jar, spring-webmvc.jar dwr.jar upgraded to spring version 5.1.7 dwr version 3.0.2 We started facing multiple issues 1. DWR servlet didn't get initialized properly; and complains about Duplicate name found while loading the context, and another problem our web.xml trying to inialize both servlets i.e. DispacterServlet and DwrSpringServlet 2. After

Forward to JSP within Spring Controller after form submission

人盡茶涼 提交于 2020-01-25 10:05:46
问题 Using Spring @Controller , @RequestMapping and @ModelAttribute , I'd like to achieve a basic form submission flow in which the user is forwarded to a new JSP with attributes set. Spring provides different ways to achieve this, but I have received various errors. Example 1 Based on tutorial: https://www.baeldung.com/spring-mvc-form-tutorial form.html <form action="/submitForm" method="POST"> <input type="text"id="field1" name="field1"> <!-- other input fields --> <button type="submit">Submit<

How ti fix the “You do not have permission to view this directory or page.” issue in Azure web app services?

可紊 提交于 2020-01-25 09:51:26
问题 I have a simple web app which if I deploy to Azure through Intelij (Using Azure App plugin ) the app works perfectly. But when I tried deploying using Jenkins the log says deployment successful , but when I try to navigate to the site it says "You do not have permission to view this directory or page." Am I missing anything ? As per my understanding as My project is working fine when deployed using Intelij, but not working through Jenkins, so the problem will be in my Jenkins Job. Here is the

Requestmapping from angular-ui-router and spring mvc

旧城冷巷雨未停 提交于 2020-01-25 08:23:06
问题 I am using AngulaJS as a javascript client side and spring mvc as a rest backend. In AngulaJS i am using ui-router. Here is config.js file function config($stateProvider, $urlRouterProvider) { $urlRouterProvider.otherwise("/index"); $stateProvider .state('trains', { url: "/trains", templateUrl: "views/pages/trains.html", data: { pageTitle: 'Trains' } }) Below is html file (left-sliderbar.html <li ui-sref-active="active"> <a href="javascript:;" ui-sref="trains" title="the trains">Trains </a> <

Prototype scope bean in controller returns the same instance - Spring Boot

陌路散爱 提交于 2020-01-25 07:56:44
问题 I have a contoller which is defined as below: @RestController public class DemoController { @Autowired PrototypeBean proto; @Autowired SingletonBean single; @GetMapping("/test") public String test() { System.out.println(proto.hashCode() + " "+ single.hashCode()); System.out.println(proto.getCounter()); return "Hello World"; } } And i have defined prototype bean as below: @Component @Scope(value= ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class PrototypeBean { static int i = 0; public int

Is it important to use Maven in Spring MVC project?

怎甘沉沦 提交于 2020-01-25 07:36:07
问题 I just started developing a project in Spring MVC and i want to know how important Maven is. 回答1: The following are the key features of Maven : Simple project setup that follows best practices - get a new project or module started in seconds Consistent usage across all projects - means no ramp-up time for new developers coming onto a project Superior dependency management including automatic updating, dependency closures (also known as transitive dependencies) Able to easily work with