我的服务类.
@Service
@Transactional(value = "transactionManager", readOnly = true, propagation = Propagation.REQUIRED)
public class DeviceServiceImpl{
@Transactional(readOnly = false)
public void blockAllDevices(){
createSmsDeviceBlock();
}
public void createSmsDeviceBlock(){
addToLogTables();
smsService.sendSms();
}
@Transactional(readOnly = false,propagation = Propagation.REQUIRES_NEW)
public void addToLogTables(){
try {
//save object with DAO methods...
} catch (Exception e) {
throw new ServiceException(ServiceException.PROCESSING_FAILED, e.getMessage(), e);
}
}
Run Code Online (Sandbox Code Playgroud)
}
从我的控制器,服务方法blockAllDevices()被调用.addToLogTables()方法被标记为Propergation.REQUIRED_NEW,但问题是addToLogTables()方法没有创建新事务并且现有事务正在使用.
我想要做的是,addToLogTables()方法上的事务应该在执行smsService.sendSms()方法之前提交.
我的问题在于,如果事务无法提交,则在方法addToLogTables()方法中,它不应该执行smsService.sendSms()方法.
我需要将带有ajax参数的'+'字符传递给我的控制器.
带参数的Ajax Call包含'+'字符.
var subsNumbers = '+94'
var url = 'getList?subsNums='+subsNumbers;
$.ajax({
url:url,
type:'POST',
dataType:'json',
success:function (saveResponse) {
....
}
});
Run Code Online (Sandbox Code Playgroud)
在我的控制器(Spring控制器类)中,
String deviceNumbers = request.getParameter("subsNums");
logger.debug("deviceNumbers-->{}", deviceNumbers);
Run Code Online (Sandbox Code Playgroud)
'+'字符已替换为空格.实际结果是
deviceNumbers--> 94
Run Code Online (Sandbox Code Playgroud)
预计是
deviceNumbers-->+94
Run Code Online (Sandbox Code Playgroud) ajax ×1
java ×1
javascript ×1
jquery ×1
parameters ×1
propagation ×1
required ×1
requires ×1
spring ×1
transactions ×1