use*_*222 5 java rest spring spring-security
我的应用程序是使用spring框架开发的.我使用spring框架创建了一个新的rest webservice.
@Controller
public class MyTestController {
@Inject
private MyService service;
@RequestMapping(value = "/acc/Status/{accNum}", method = RequestMethod.GET)
@ResponseBody
public String getAccStatus(@PathVariable final String accNum, final HttpServletResponse response) throws Exception
{
//logic goes here
return "success";
}
Run Code Online (Sandbox Code Playgroud)
为MyService:
public interface BusinessCalendarService {
//methods..
}
Run Code Online (Sandbox Code Playgroud)
我想看看上面的webservice的响应.我正在使用邮差工具查看回复.当我将请求作为
http:// localhost:8080/myApplication/rest/acc/Status/322298973发出时,它显示以下消息.
HTTP Status 401 - Full authentication is required to access this resource
Run Code Online (Sandbox Code Playgroud)
现有的控制器工作正常,它与我的控制器显示上述消息.请建议我是否需要进行任何代码修改?我按照与编写其他控制器相同的方式进行操作.
您需要在发布到该 uri 之前对用户进行身份验证,或者,如果它是无需经过身份验证即可访问的 uri,请将 uri 添加到authorizeRequests().antMatcher()配置的 http 安全部分中。
| 归档时间: |
|
| 查看次数: |
8108 次 |
| 最近记录: |