2. $a=-2, b=-4$ Detailed explanation: The condition for the function $f(x)$ to be continuous at $x=1$ is $\lim _{x \rightarrow 1} f(x)=f(1)$, i.e., $\lim _{x \rightarrow 1} f(x)=1$.
$$
\because \lim _{x \rightarrow 1} f(x)=\lim _{x \rightarrow 1}\left(\frac{a}{1-x}-\frac{b}{1-x^{2}}\right)=\lim _{x \rightarrow 1} \frac{a x+a-b}{(1-x)(1+x)}, \therefore\left\{\begin{array} { l } 
{ a + ( a - b ) = 0 } \\
{ \operatorname { l i m } _ { x \rightarrow 1 } \frac { - a } { 1 + x } = 1 }
\end{array} \Leftrightarrow \left\{\begin{array}{l}
b=-4 \\
a=-2
\end{array}\right.\right.
$$
2. If the function $f(x)=\left\{\begin{array}{l}\frac{a}{1-x}-\frac{b}{1-x^{2}}, x \neq \pm 1 \\ 1, x=1\end{array}\right.$ is continuous at $x=1$, then the constant $a=$ $\qquad$ $b=$ . $\qquad$