spring-mvc

Enable HTTP Request POST in Spring Boot

流过昼夜 提交于 2020-05-14 17:15:21
问题 I am using Spring boot, here the maven dependency <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> For the web pages I am placing the files in src/main/resources/static. There I have my html files, js libraries (angular, jquery), and css files. I am trying to make an HTTP Request POST with Angular (I also have a GET Request that is working fine) but I get this POST http://localhost:8080/xxxx/12/addEntry 405 (Method Not

Update User's first name and last name in principal

你说的曾经没有我的故事 提交于 2020-05-14 10:23:05
问题 I am updating user's information like first name and last name and I am getting first name and last name in all the pages for welcome message . I have two controllers one for ajax request mapping and the other for normal request mapping. Normal request mapping controller have this method. In this controller all page navigation is present and some request mapping which are not ajax calls private String getPrincipalDisplay() { GreenBusUser user = null; String userName = ""; Object principal =

Update User's first name and last name in principal

此生再无相见时 提交于 2020-05-14 10:22:28
问题 I am updating user's information like first name and last name and I am getting first name and last name in all the pages for welcome message . I have two controllers one for ajax request mapping and the other for normal request mapping. Normal request mapping controller have this method. In this controller all page navigation is present and some request mapping which are not ajax calls private String getPrincipalDisplay() { GreenBusUser user = null; String userName = ""; Object principal =

Update User's first name and last name in principal

倖福魔咒の 提交于 2020-05-14 10:22:20
问题 I am updating user's information like first name and last name and I am getting first name and last name in all the pages for welcome message . I have two controllers one for ajax request mapping and the other for normal request mapping. Normal request mapping controller have this method. In this controller all page navigation is present and some request mapping which are not ajax calls private String getPrincipalDisplay() { GreenBusUser user = null; String userName = ""; Object principal =

Having Multiple Exception classes aren't like Redundant, especially when we are using Error Codes?

早过忘川 提交于 2020-05-14 08:45:32
问题 I am using Spring Boot and Spring Rest in our app. My query is : In our app, we are using Error Codes, along with creating Multiple Exception classes. So, When we already using Custom Error Codes, whats the point to create Multiple Exception classes again? I am thinking to have create only One Custom Exception class for the whole App(say AppException), should be enough to display Error Response for all kinds of Error scenarios using Error Codes. Okay, even for logs, we can show same Exception

Checkmarx Java fix for Log Forging -sanitizing user input

血红的双手。 提交于 2020-05-14 07:36:31
问题 Can anyone suggest the proper sanitization/validation process required for the courseType variable in the following getCourses method. I am using that variable to write in a log file. I've tried HtmlUtils.HtmlEscape() but didn't get expected results. Thanks! @RequestMapping(value = "/retriveCourses", method = RequestMethod.GET) @ResponseBody public List<Course> getCourses(@RequestParam(value = "courseType", required = false) String courseType) { } 回答1: it seems like the Checkmarx tool is

Spring boot create a duplication of record from mysql

人盡茶涼 提交于 2020-05-13 19:26:31
问题 i have a record of data entity is given as follows in primary key @GeneratedValue(strategy = GenerationType.IDENTITY) @Id @Column(name = "id",unique = true,nullable = false) public Long id; what i have tried and even tried with object mapper which has some other issues Record abc =dao.findById(11); abc.setId(Null); //not working dao.save(abc) //not working so what i am trying to do is a record with primary key as 1 when saved it should save as a new record ? 回答1: you should create a new

Spring boot create a duplication of record from mysql

大城市里の小女人 提交于 2020-05-13 19:26:07
问题 i have a record of data entity is given as follows in primary key @GeneratedValue(strategy = GenerationType.IDENTITY) @Id @Column(name = "id",unique = true,nullable = false) public Long id; what i have tried and even tried with object mapper which has some other issues Record abc =dao.findById(11); abc.setId(Null); //not working dao.save(abc) //not working so what i am trying to do is a record with primary key as 1 when saved it should save as a new record ? 回答1: you should create a new

Spring security 401 Unauthorized even with permitAll

风流意气都作罢 提交于 2020-05-13 13:14:12
问题 I'm using Spring security to secure some endpoints in my REST service. here's the security configuration class: @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(securedEnabled = true, jsr250Enabled = true, prePostEnabled = true) public class SecurityConfig extends WebSecurityConfigurerAdapter { // Other methods @Override protected void configure(HttpSecurity http) throws Exception { http .cors() .and() .csrf() .disable() .exceptionHandling() .authenticationEntryPoint(this

Spring security 401 Unauthorized even with permitAll

别来无恙 提交于 2020-05-13 13:12:11
问题 I'm using Spring security to secure some endpoints in my REST service. here's the security configuration class: @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(securedEnabled = true, jsr250Enabled = true, prePostEnabled = true) public class SecurityConfig extends WebSecurityConfigurerAdapter { // Other methods @Override protected void configure(HttpSecurity http) throws Exception { http .cors() .and() .csrf() .disable() .exceptionHandling() .authenticationEntryPoint(this