Well-posed optimization problems for integral functionals