@Controller
public class MyController {
@Autowired
MyService service;
@RequestMapping("/test")
@ResponseBody
public String hello() {
service.save();
return "h";
}
}
service
@Controller
public class MyController {
@Autowired
MyService service;
@RequestMapping("/test")
@ResponseBody
public String hello() {
service.save();
return "h";
}
}
service
service is a singleton, and whether there is a thread safety problem depends on the service itself.
in your case, service.save should store objects directly in the database without thread safety problems, and all concurrency problems are left to db management.
Why did spring fail to automatically match fields? Wechat s front end reads as follows: Java: ...
excuse me: String SCOPED_TARGET_NAME_PREFIX = "scopedTarget. "; under what circumstances will this prefix be used? public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMapping implements InitializingBean { ** ...
learn the problems encountered when the converter: now the time to convert the String format sent from the foreground into the date format, the converter only specifies the format before conversion string and the format after conversion date, but the fo...
such as the title. background controller: @RequestMapping("generatorOrder") public TMessage generatorOrder(Order order) { ... } order class: public class Order implements Serializable { private Long orderId; ...
RT. I want to verify that in the request InnerValidatedRequest, if the fields houseName and houseAddress, in the InnerValidatedRequestData member object are annotated with the @ Validated of SpringMVC, what else do you need to add? if this is the c...
error prompt use: <dependency> <groupId>org.springframework< groupId> <artifactId>spring-orm< artifactId> <version>4.3.14.RELEASE< version> < dependency> <depend...
,,Spring mvc: <context:component-scan base-package="..." > @Controller,@RequestMapping. ,<context:component-scan base-package="" >Spring, Spring mvc,? ...
how should I open the index implementation on the home page of the website to query the relevant data from the background database and then bind it to the page? ...
divided into two parts, the first part, let s take a look at the error message , the second part, look at the code logic . part I: error message: GoShopping :: Entity DAO DAO Mapper in namespace in mapper, there is no such path as s...
as shown in the figure I created a route for a fan domain name. Parsing all requests directly opens the same vue single page; then parse the specific route through vue-router . due to the need to verify the login authorized by Wechat, all can ...
wants to implement such a function through a custom interceptor: if the client requests that the file website img abc.jpg exists, it will be returned, if it does not exist, the file will be created and returned. May I ask how to achieve it? ...
has an entity class with two attributes, startNum and endNum. so how to verify that startNum must be less than endNum? by javavalidation ...
for example, I learned about the introduction to spring websocket through the following URL https: spring.io guides gs m. but guides only talks about broadcast websocket, but I want to know how to implement the peer-to-peer websocket function. Is th...
spring intercepts localhost:8080 1 to intercept my chat page, but not to the root directory. Go back to the default index page; console has such important several lines of log output 2018-06-04 15:46:03.601 INFO 15836 --- [ restartedMain] o.s.w.s...
I searched for it all day and found a similar answer to the google, that I was able to get home, but I don t think I can make it clear where this user came from. my English is not good, and I use translation software, which may be the reason why I can...
the following error should be related to the injection of the data source! But why can it be solved by introducing spring-jdbc as a jar package? spring-jdbcjar:(): : Exception encountered during context initialization - cancelling refresh attempt: o...
in the following Spring mvc code, why did the creation of bean fail? I have added < context:component-scan base-package= " " > to the springmvc.xml file . where the project directory structure is cause of error report: Caused by: org.springfra...
spring intercepts localhost:8080 1 to intercept my chat page, but not to the root directory. Go back to the default index page; there are several lines of log output in the console log 2018-06-04 15:46:03.601 INFO 15836 --- [ restartedMain] o.s.w.s...
does Spring: controller need to provide an interface like service, and then write an Impl class? ...
effect you want to achieve: all access except static ** is implemented by a single controller. as shown in figure expects the HomeController@index method to handle all requests, except for the static ** path. the above code can t rea...