我需要将可变列表对象转换为不可变列表,在java中可能的方式是什么.
public void action() {
List<MutableClass> mutableList = Arrays.asList(new MutableClass("san", "UK", 21), new MutableClass("peter", "US", 34));
List<MutableClass> immutableList = immutateList(mutableList);
}
public List<MutableClass> immutateList(List<MutableClass> mutableList){
//some code here to make this beanList immutable
//ie. objects and size of beanList should not be change.
//ie. we cant add new object here.
//ie. we cant remove or change existing one.
}
Run Code Online (Sandbox Code Playgroud)
MutableClassfinal class MutableClass {
final String name;
final String address;
final int age;
MutableClass(String name, String address, int age) { …Run Code Online (Sandbox Code Playgroud) 企业服务总线(充当调解器,消息代理,服务启用器,架构转换增强器,透明位置提供程序,服务聚合器,负载平衡器,监视器以及所有这些东西的工具)是否负责协调服务?
如何在企业服务总线中放置超过一千步和几十个服务调用的自动化业务流程?
你会这样做,还是会使用编排专家如BPEL引擎?
请给你意见.
我知道我可以使用web.config中的授权标记来限制对ASP.NET MVC 3应用程序的访问
<authentication mode="Windows"></authentication>
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" />
<authorization>
<allow roles="MyDomain\MyGroup" />
<deny users="*" />
<deny users="?" />
</authorization>
或使用[Authorize()]属性(甚至使用自定义Authorize属性)装饰控制器基类
[AdminOnly]
public class BaseController : Controller{}
Run Code Online (Sandbox Code Playgroud)
问题是:他们是替代方法和等效方法吗?我应该总是使用一种方法而不是另一种方法吗?我应该记住哪些元素?
我开始使用 .NET 6 Web API。我写了一个非常简单的控制器:
[Route("[controller]")]
[ApiController]
public class TestController : ControllerBase
{
[HttpGet,Route("sample")]
public IActionResult ReturnSample(string ParameterOne, string ParameterTwo)
{
[... do something ...]
}
}
Run Code Online (Sandbox Code Playgroud)
问题是所有参数都是强制性的。
网址:https://<server>/test/sample?ParameterOne=Value&ParameterTwo=Value
工作正常,一切OK
网址:https://<server>/test/sample?ParameterOne=Value&ParameterTwo=
错误:
{
"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title":"One or more validation errors occurred.",
"status":400,
"traceId":"00-dc73d9983b53750d2073c48bec522c70-98fe251af1accccf00",
"errors":{"ParameterTwo":["The ParameterTwo field is required."]}}
Run Code Online (Sandbox Code Playgroud)
如何允许空值作为参数的有效值?
谢谢洛伦佐