小编Din*_*nka的帖子

spring transaction management Propagation.REQUIRES_NEW无效

我的服务类.

@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()方法.

spring transactions propagation required requires

3
推荐指数
1
解决办法
4101
查看次数

javascript无法使用ajax参数发送'+'字符

我需要将带有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)

javascript java parameters ajax jquery

0
推荐指数
1
解决办法
899
查看次数