Spring MVC - RequestMapping - Execute only if a parameter is not present - spring-mvc

I'm making a test and I'm not able to answer correctly the following question:
Modify the Spring MVC handler method to only run if the parameter Bill is not present:
#RequestMapping(value="/getQuote", [...])
The correct answer should be the following (negating the parametert Bill):
params = "!Bill"
and the complete annotation should be the following:
#RequestMapping(value="/getQuote", params = "!Bill")
But this doesn't result the correct answer.
Where Am I wrong?
Can you help me?
Thanks and Regards,
Vincenzo

#RequestMapping(value="/getQuote", params = "!Bill")
This looks fine to me.
I assume you're doing some kind of online test/exam which may not handle whitespaces correctly. Try it without spaces between params and ="!Bill".

Related

Registering a new identifier on developer.apple denotes that bundle identifier is "invalid"

So, I am trying to publish my Xamarin.Ios app to the app store (really test flight but I have to get an ipa) I'm following along the Microsoft documentation and trying to register a new identifier, however, when I insert my Bundle ID (gotten from info.plist) the web service marks it as "invalid identifier". I've been looking to see if I glanced over a pre-requisite in the documentation but I haven't noticed anything. Any help with this issue would be greatly appreciated. Thank you for your time.
It turns out that I had an underscore in my bundle id and that was the issue, ostensibly changing it to ascii code will fix the issue. However, I'm unsure of how to change it exactly, for instance, _ is 95 using ascii code but if I have blah_app and change it to blah95app that would allow me to register but I'm not sure if that is in the correct format.

NavigationParameters - GetNavigationMode() is NULL while mocking NavigationParameters.

I tried mocking NavigationParameters and it is setting GetNavigationMode() as NULL. Is there any better way to mock an extension method?
Didn't work out for me. But your reference helped me to find a solution, that compiled (maybe it is a version issue, I use Prism 7.1:
var navParams = (INavigationParametersInternal)new NavigationParameters();
navParams.Add("__NavigationMode", NavigationMode.New);
This was bugging me for a while as well, and I finally found something that is at least a workaround. This issue shows that you can actually add internal parameters to the NavigationParameters, it just doesn't show up in intellisense. My test code ended up looking something like:
var navParams = new NavigationParameters();
navParams.AddInternalParameter("__NavigationMode", NavigationMode.Back);
Hope this helps!
As noted by #thomas-kison, the AddInternalParameter api no longer seems to exist. A search through the Prism repo only brings up the issue referenced by #batesiiic in their answer.
To add to #thomas-kison's answer by addressing #esteban-chornet's question, what I've found is that this solution will work by passing in the INavigationParametersInternal argument as INavigationParameters:
// arrange:
var navParams = (INavigationParametersInternal)new NavigationParameters();
navParams.Add("__NavigationMode", NavigationMode.Back);
// act:
_myCoolPageViewModel.OnNavigatedTo(navParams as INavigationParameters);
// assert whatever should happen in OnNavigatedTo given a NavigationMode of NavigationMode.Back
Hope this helps someone out!

CQ5 SlingServlet and resourceTypes not working for specific resource paths

If I define a Sling Servlet as follows:
#SlingServlet(
label="TestResourceTypeServlet",
name = "com.company.project.servlets.TestResourceType",
extensions = {"bob"},
resourceTypes= {"cq:Page"},
methods= {"GET"},
metatype=true)
#Properties({
#Property(name = "service.description", value = "A test servlet"),
#Property(name = "service.vendor", value = "Company")
})
The servlet picks up any get request to every page with an extension of '.bob', which is fine but what I really want is to handle a request to a specific page type,
SO
I modify resourceTypes to read
resourceTypes= {"site-administration/components/page/page-distribution"},
the supplied value is the specific sling:resourceType (copied and pasted out of CRXDE Lite) of a page I am trying to access with the .bob extension, but I get a 404!!!
All the documentation I've read says the above should work, but it does not.
Out of desperation I've even tried "site-administration/components/page" which is the super type of the page I want.
I'm running a clean 5.6.1 instance with this servlet as part of an OSGi bundle.
Am I missing something obvious here, or if not is anyone aware of any hot fixes that could resolve this issue ?
Any help would be appreciated as I'm starting to go slightly mad in the head.
EDIT
Ok, so I've gotten a little further: If I access the page with:
[path-to-page]/page.bob.html
The servlet fires. But in this URL is bob not a selector? and if so why when the resource type is cq:Page does the configuration work with bob as an extension?
Very confused :-S
I'm obviously missing something very simple here.
The problem with pages is that the resourceType is stored on the jcr:content node below the cq:Page node. If you would call [path-to-page]/_jcr_content.bob it should work. Note: _jcr_content is an url save version of jcr:content.
Why your last example is actually working, I cannot tell.

ASP.NET MVC 2 - How to ignore an entire directory using IgnoreRoute?

I've tried the following two methods to try and ignore my "Assets" folder, but I keep coming up with errors. Can anyone tell me exactly how the Ignore Regex is supposed to look?
routes.IgnoreRoute("/Assets/")
routes.IgnoreRoute("{*assets}", New With {.assets = "\/Assets\/(.*)"})
Try
routes.RouteExistingFiles = false
routes.IgnoreRoute("Assets/{*pathInfo}")
routes.IgnoreRoute("Ignore/");
will prevent the standard
The controller for path '/Crap/Home' was not found or does not implement IController.
Asp.net mvc exception.

How to do a custom asp.net routing (hardcoding the controller)

I'm trying to create a route for the following urls:
www.mysite.com/user/username
www.mysite.com/user/username/pictures
I tried doing that with the following code:
routes.MapRoute(
"UserProfile",
"user/{sn}/{action}",
new { controller = "User", action = "Index", sn = "" }
);
So if an action is not specified, you go to the index action.
However, it's not working and I'm not sure what I'm doing wrong.
Thanks for any help.
Looks like your code is correct.
The order of the rules is important. Try to place this above all other rules.
And if it will intefere with other rules, you should provide some constraints for the best matches.
I agree with maxnk, the code looks correct, it's probably just an ordering thing. I'd suggest checking out the Route Debugger that Phil Haack wrote: http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx. It's very useful for these tricky route-ordering issues

Resources